-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.js
51 lines (46 loc) · 1.27 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
const { app, BrowserWindow } = require('electron')
let win = null;
const lock = app.requestSingleInstanceLock();
if (!lock) {
app.quit()
} else {
app.on('second-instance', (event, commandLine, workingDirectory) => {
if (win) {
if (win.isMinimized()) win.restore()
win.focus()
}
})
}
function createWindow() {
win = new BrowserWindow({
width: 800,
height: 610,
icon: __dirname + '/icon.png',
webPreferences: {
nodeIntegration: true,
contextIsolation: false
},
autoHideMenuBar: true,
resizable: true,
show: false
})
splash = new BrowserWindow({ width: 600, height: 350, frame: false, transparent: true, alwaysOnTop: true, icon: __dirname + '/icon.png' })
splash.loadFile(__dirname + '/renderer/splash.html')
win.loadFile(__dirname + '/renderer/index.html')
win.addListener('ready-to-show', () => {
splash.destroy();
win.show()
win.removeMenu()
})
}
app.whenReady().then(() => {
createWindow()
app.on('activate', () => {
if (BrowserWindow.getAllWindows().length === 0) {
createWindow()
}
})
})
app.addListener('window-all-closed', () => {
if (process.platform !== 'darwin') app.quit()
})