-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathindex.js
48 lines (37 loc) · 1.09 KB
/
index.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, Menu, screen, Tray } = require('electron');
require('electron-reload')(__dirname);
const createWindow = () => {
const { width, height } = screen.getPrimaryDisplay().workAreaSize;
Menu.setApplicationMenu(false);
window = new BrowserWindow({
width: width / 1.25,
height: height / 1.25,
webPreferences: {
nodeIntegration: true
}
});
window.on('minimize', e => {
e.preventDefault();
window.hide();
});
window.on('close', e => {
e.preventDefault();
window.hide();
});
window.loadFile('public/index.html');
};
let appIcon = null;
let window = null;
app.whenReady().then(createWindow)
app.on('window-all-closed', () => app.quit());
app.on('ready', () => {
appIcon = new Tray('public/favicon.png');
const contextMenu = Menu.buildFromTemplate([
{ label: 'Show', click: () => window.show() },
{ label: 'Quit', click: () => {
window.destroy();
app.quit();
}}
]);
appIcon.setContextMenu(contextMenu);
});