-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
67 lines (55 loc) · 1.57 KB
/
Copy pathmain.js
File metadata and controls
67 lines (55 loc) · 1.57 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
const {
app,
BrowserWindow,
ipcMain,
nativeImage
} = require('electron')
const path = require('path')
const eventHandler = require('./event')
const url = require('url');
process.env['ELECTRON_DISABLE_SECURITY_WARNINGS'] = 'true';
if(require('electron-squirrel-startup')) app.quit();
function createWindow() {
var win = new BrowserWindow({
width: 600,
height: 500,
webPreferences: {
nodeIntegration: true,
contextIsolation: false, // Very important: https://www.electronjs.org/docs/tutorial/context-isolation
preload: path.join(__dirname, 'preload.js')
},
icon: nativeImage.createFromPath(__dirname +'/public/favicon_io/favicon.ico'),
center: true
})
// win.webContents.openDevTools()
console.info('process.env', process.env.isDev);
const startUrl = process.env.isDev? "http://localhost:3000" : url.format({
pathname: path.join(__dirname, 'build/index.html'),
protocol: 'file:',
slashes: true
});
// win.loadFile('index.html')
win.loadURL(startUrl);
// Emitted when the window is closed.
win.on('closed', function () {
// Dereference the window object, usually you would store windows
// in an array if your app supports multi windows, this is the time
// when you should delete the corresponding element.
win = null
})
// console.info('eventHandler', eventHandler);
eventHandler(ipcMain, win)
}
app.whenReady().then(() => {
createWindow()
app.on('activate', () => {
if (BrowserWindow.getAllWindows().length === 0) {
createWindow()
}
})
})
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
app.quit()
}
})