-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.js
More file actions
51 lines (43 loc) · 1.15 KB
/
main.js
File metadata and controls
51 lines (43 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
const { app, BrowserWindow, globalShortcut } = require('electron');
let win;
const SCROLLBAR_FIX_CSS = `
html, body, #GameDiv, #Cocos3dGameContainer, #GameCanvas {
width: 100% !important;
height: 100% !important;
margin: 0 !important;
overflow: hidden !important;
}
`;
function createWindow() {
win = new BrowserWindow({
width: 1280,
height: 720,
webPreferences: {
devTools: false
}
});
win.loadFile('pvzge_web/docs/index.html');
win.webContents.on('did-finish-load', () => {
win.webContents.insertCSS(SCROLLBAR_FIX_CSS).catch((err) => {
console.error('Failed to inject scrollbar fix CSS:', err);
});
});
win.removeMenu(); // hides the top menu bar
// Register shortcuts for fullscreen toggle
globalShortcut.register('F4', () => {
win.setFullScreen(!win.isFullScreen());
});
globalShortcut.register('F11', () => {
win.setFullScreen(!win.isFullScreen());
});
}
app.whenReady().then(createWindow);
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
app.quit();
}
});
app.on('will-quit', () => {
// Unregister all shortcuts
globalShortcut.unregisterAll();
});