-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathmain.js
More file actions
44 lines (35 loc) · 925 Bytes
/
main.js
File metadata and controls
44 lines (35 loc) · 925 Bytes
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
const { app, BrowserWindow } = require('electron');
require('electron-reload')(__dirname);
// keep reference to window object otherwise it will be
// closed automatically when the JS object is garbage collected.
let win;
function createWindow () {
// start express server
app.server = require(__dirname + '/server.js')();
// configure window and load app
if (process.env.NODE_ENV == 'production') {
win = new BrowserWindow({ fullscreen: true });
} else {
win = new BrowserWindow({
width: 1200,
height: 1000
});
win.webContents.openDevTools();
}
win.loadURL('http://localhost:3000');
win.on('closed', () => {
win = null
})
}
app.on('ready', createWindow);
// quit when all windows are closed.
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
app.quit()
}
});
app.on('activate', () => {
if (win === null) {
createWindow()
}
});