-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.js
84 lines (67 loc) · 1.78 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
72
73
74
75
76
77
78
79
80
81
82
83
84
const { app, BrowserWindow,dialog, Notification,Tray,Menu } = require('electron')
const {globalShortcut} = require('electron')
const storage = require('electron-storage')
var path = require('path')
let win
let tray = null
function createWindow () {
win = new BrowserWindow({
width: 425,
height: 500,
frame: false,
transparent: false,
resizable:false,
icon:__dirname + '/src/images/clock.png',
webPreferences: {
nodeIntegration: true
}
})
globalShortcut.register('f5', function() {
console.log('f5 is pressed')
win.reload()
})
globalShortcut.register('f8', function() {
storage.remove('token.json', err => {
if (err) {
console.log(err)
}
});
})
globalShortcut.register('CommandOrControl+Z', function() {
console.log('CommandOrControl+Z+R is pressed')
storage.remove('token.json', err => {
if (err) {
console.log(err)
}
});
})
globalShortcut.register('CommandOrControl+R', function() {
console.log('CommandOrControl+R is pressed')
win.reload()
})
win.loadURL(`file://${__dirname}/src/html/index.html`)
//win.webContents.openDevTools()
win.on('closed', () => {
win = null
})
}
app.on('ready', () => {
tray = new Tray(__dirname+'/src/images/clock.ico')
const contextMenu = Menu.buildFromTemplate([
{ label: 'Reload', click:function(){win.reload()} },
{ label: 'Delete Token', click:function(){ storage.remove('token.json', err => {if (err) {console.log(err)}});} },
{ label: 'Exit', click:function(){app.quit()} },
])
tray.setContextMenu(contextMenu)
createWindow()
})
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
app.quit()
}
})
app.on('activate', () => {
if (win === null) {
createWindow()
}
})