-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
67 lines (56 loc) · 1.47 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
const {app, BrowserWindow} = require('electron')
const url = require('url');
const path = require('path');
const Server = require('./app.js') // initialize the server
let mainWindow
const server = new Server((res) => {
if (process.env.NODE_ENV !== 'production') {
mainWindow.loadURL('http://localhost:2003');
} else {
mainWindow.loadURL(
url.format({
pathname: path.join(__dirname, './dist/index.html'),
protocol: 'file:',
slashes: true
})
)
}
});
server.start()
// Create the window
function createWindow() {
mainWindow = new BrowserWindow({
width: 800,
height: 600,
fullscreen: true,
webPreferences: {
nodeIntegration: true,
// This enables us to do CORS requests. Needed for VolmueMixer icon retrieval retrying
webSecurity: false,
},
})
mainWindow.on('closed', function() {
mainWindow = null
server.kill() // Kill the node server
})
console.log('Created window')
}
// When electron is ready, load the pug file and its settings and render it
app.on('ready', async () => {
// Create window
createWindow()
mainWindow.loadURL('http://localhost:3000/tablet')
})
app.on('window-all-closed', function() {
if(process.platfornm !== 'darwin') {
app.quit()
server.kill() // Kill the node server
}
})
app.on('activate', function() {
if(mainWindow == null) {
createWindow()
}
})
// Disable Electron warnings
process.env['ELECTRON_DISABLE_SECURITY_WARNINGS'] = 'true';