-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
executable file
·51 lines (48 loc) · 1.34 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
49
50
51
const { app, BrowserWindow, Menu, Tray, Notification } = require('electron');
let win = null;
let tray = null
Menu.setApplicationMenu(null);
let close = false
function createWindow() {
tray = new Tray(__dirname + '/dida.png')
win = new BrowserWindow();
// win.webContents.openDevTools();
var trayMenuTemplate = [
{
label: '显示/隐藏',
click: function () {
win.isVisible() ? win.hide() : win.show();
win.isVisible() ? win.setSkipTaskbar(false) : win.setSkipTaskbar(true);
}
},
{
label: '退出',
click: function () {
close = true;
app.quit();
}
}
];
const contextMenu = Menu.buildFromTemplate(trayMenuTemplate);
tray.setContextMenu(contextMenu);
win.on('close', (event) => {
if (!close) {
event.preventDefault();
win.hide();
win.setSkipTaskbar(true);
}
})
win.loadURL('https://dida365.com/signin');
}
const gotTheLock = app.requestSingleInstanceLock();
if (!gotTheLock) {
app.quit()
} else {
app.on('second-instance', (event, commandLine, workingDirectory) => {
if (win) {
if (win.isMinimized()) win.restore()
win.focus()
}
})
}
app.on('ready', createWindow)