-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
58 lines (57 loc) · 1.64 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
52
53
54
55
56
57
58
const { app, BrowserWindow, Menu, Tray, ipcMain } = require('electron')
let tray = null;
function createWindow() {
const mainWindow = new BrowserWindow({
width: 450,
height: 134,
resizable: false,
webPreferences: {
nodeIntegration: true
},
icon: "bin/icon.png",
frame: false
});
mainWindow.loadFile('src/index.html');
Menu.setApplicationMenu(null);
ipcMain.on('closing', function(event, arg) {
mainWindow.hide();
tray = new Tray("bin/icon.png");
const contextMenu = Menu.buildFromTemplate([
{ label: 'Cot Hypernet', enabled: false, icon: 'bin/icon16.png' },
{ type: 'separator' },
{
label: 'Show',
click: function() {
mainWindow.show();
tray.destroy();
tray = null;
}
},
{ label: 'Exit', click: function() {
mainWindow.webContents.send("fclose");
} },
])
tray.setToolTip('Cot Hypernet');
tray.setContextMenu(contextMenu);
tray.on('click', () => {
mainWindow.show();
tray.destroy();
tray = null;
})
});
ipcMain.on("exitingss", function(event, arg){
app.quit();
})
//mainWindow.webContents.openDevTools({mode:'detach'});
}
app.whenReady().then(createWindow)
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
app.quit()
}
})
app.on('activate', () => {
if (BrowserWindow.getAllWindows().length === 0) {
createWindow()
}
})