-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.js
71 lines (63 loc) · 2.03 KB
/
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
const { app, BrowserWindow, Menu, Tray } = require('electron')
const path = require("path");
const { connectionListener, fetchStatus, fetchConfig, killProcess } = require('./modules/ipc');
let mainWindow = null;
let tray = null
const loadMainWindow = () => {
mainWindow = new BrowserWindow({
width : 650,
height: 525,
resizable:false,
title: 'Haltdos VPN Client',
icon: __dirname + '/static/assets/img/icon_light.png',
webPreferences: {
nodeIntegration: true,
preload: path.join(__dirname, 'modules/preload.js')
}
});
mainWindow.loadFile(path.join(__dirname, "static/index.html"));
mainWindow.setMenuBarVisibility(true);
app.setAppUserModelId(process.execPath)
}
app.on("ready", () => {
loadMainWindow();
let contextMenu = Menu.buildFromTemplate([
{ label: 'Show', type: 'normal', click: function(){mainWindow.show()} },
{ label: 'Quit', type: 'normal', click: function(){app.isQuiting = true; app.quit()}}
])
mainWindow.on('minimize', function (event) {
event.preventDefault();
mainWindow.hide();
tray = new Tray(__dirname + '/static/assets/img/icon_light.png');
tray.setToolTip('Haltdos VPN Client');
tray.setContextMenu(contextMenu);
})
mainWindow.on('show', function (event) {
event.preventDefault();
tray.destroy();
})
mainWindow.on('close', function (event) {
if (!app.isQuiting) {
event.preventDefault()
}
mainWindow.hide()
tray = new Tray(__dirname + '/static/assets/img/icon_light.png')
tray.setToolTip('Haltdos VPN Client')
tray.setContextMenu(contextMenu)
})
});
app.on("window-all-closed", () => {
if (process.platform !== "darwin") {
app.quit();
}
});
app.on("activate", () => {
if (BrowserWindow.getAllWindows().length === 0) {
loadMainWindow();
}
});
//Initializing IPC Channel Functions
connectionListener();
fetchStatus();
fetchConfig();
killProcess();