-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAppTray.js
38 lines (30 loc) · 852 Bytes
/
AppTray.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
const { app, Menu, Tray } = require('electron');
class AppTray extends Tray {
constructor(icon, mainWindow) {
super(icon);
this.setToolTip('SysTop');
this.mainWindow = mainWindow;
this.on('click', this.onClick.bind(this));
this.on('right-click', this.onRightClick.bind(this));
}
onClick() {
if (this.mainWindow.isVisible() === true) {
this.mainWindow.hide();
} else {
this.mainWindow.show();
}
}
onRightClick() {
const contextMenu = Menu.buildFromTemplate([
{
label: 'Quit',
click: () => {
app.isQuitting = true
app.quit()
}
}
]);
this.popUpContextMenu(contextMenu);
}
}
module.exports = AppTray;