-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.js
50 lines (45 loc) · 1.43 KB
/
main.js
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
const { app, BrowserWindow } = require('electron')
const path = require('path')
if (require('electron-squirrel-startup')) app.quit();
const setupEvents = require('./forge.config')
if (setupEvents.handleSquirrelEvent()) {
process.exit()
}
function createWindow () {
const mainWindow = new BrowserWindow({
fullscreen: true,
fullscreenable: false,
autoHideMenuBar: true,
icon:'resources/duco.ico',
backgroundColor: '#363636',
darkTheme: true,
frame: false,
webPreferences: {
nodeIntegration: false,
contextIsolation: true,
enableRemoteModule: false,
preload: path.join(__dirname, 'js/serialports.js'),
webSecurity: false
},
});
mainWindow.removeMenu();
mainWindow.on('menu', function (e){
e.preventDefault();
});
mainWindow.webContents.session.clearStorageData();
mainWindow.webContents.session.clearCache();
mainWindow.maximize();
mainWindow.loadFile('index.html');
mainWindow.show();
mainWindow.webContents.setWindowOpenHandler(({ url }) => {
return { action: 'allow' }
});
mainWindow.webContents.on("devtools-opened", () => { mainWindow.webContents.closeDevTools(); });
}
app.whenReady().then(() => {
app.allowRendererProcessReuse = false
createWindow();
})
app.on('window-all-closed', function () {
if (process.platform !== 'darwin') app.quit()
})