-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
66 lines (64 loc) · 1.71 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
59
60
61
62
63
64
65
66
const electron = require('electron');
const {
app,
Tray,
Menu,
BrowserWindow
} = electron;
const path = require('path');
const iconPath = path.join(__dirname, 'icon.png');
let appIcon = null;
let win = null;
const ip = require('ip');
const publicIp = require('public-ip');
var ExternalIP;
var ncp = require('clipboardy');
app.on('ready', () => {
publicIp.v4().then(eip => {
ExternalIP = eip;
win = new BrowserWindow({
show: false
});
appIcon = new Tray(iconPath);
var contextMenu = Menu.buildFromTemplate([{
label: "Copy LAN IP: " + ip.address("public"),
click: function () {
ncp.writeSync(ip.address("public"));
}
},
{
label: "Copy Public IP: " + ExternalIP,
click: function () {
ncp.writeSync(ExternalIP);
}
},
{
type: 'separator'
},
{
label: 'Reload',
role: 'reload',
accelerator: 'CommandOrControl+Alt+R',
click: function () {
app.relaunch();
app.exit();
}
},
{
label: 'Quit',
accelerator: 'CommandOrControl+Q',
selector: 'terminate:',
click: function () {
app.quit();
app.exit();
}
}
]);
appIcon.setToolTip('View your Network information');
appIcon.setContextMenu(contextMenu);
});
})
app.on('quit', () => {
app.quit();
app.exit();
})