-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.js
48 lines (41 loc) · 952 Bytes
/
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
const { app, BrowserWindow, Tray, Menu } = require('electron');
const path = require('path');
let window;
let isQuiting;
let tray;
app.on('before-quit', function () {
isQuiting = true;
});
app.on('ready', () => {
// Make sure that this app starts in the tray.
tray = new Tray(path.join(__dirname, 'tray.png'));
tray.setContextMenu(Menu.buildFromTemplate([
{
label: 'Show App', click: function () {
window.show();
}
},
{
label: 'Quit', click: function () {
isQuiting = true;
app.quit();
}
}
]));
// Create the window
window = new BrowserWindow({
width: 850,
height: 450,
show: false,
});
// Load the index.html of the app .
window.loadURL('file://' + __dirname + '/index.html');
// Close the window when the window is closed but keep the task running
window.on('close', function (event) {
if (!isQuiting) {
event.preventDefault();
window.hide();
event.returnValue = false;
}
});
});