-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
86 lines (75 loc) · 2.47 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
85
86
const { app, Menu, Tray, BrowserWindow, ipcMain } = require('electron')
const path = require('path')
const { handleSquirrelEvent } = require ('./squirrel.js')
const Store = require('electron-store');
if (require('electron-squirrel-startup')) {
handleSquirrelEvent()
}
let tray = null
function boot() {
const hiddenWin = new BrowserWindow({
width: 100,
height: 100,
show: false,
frame: false,
webPreferences: {
nativeWindowOpen: true,
}
})
let settingsWindow = null
const store = new Store();
tray = new Tray(path.join(__dirname, 'icon.png'))
let contextMenu = Menu.buildFromTemplate([
{
label: 'Settings',
click: () => {
// Anything to do with the settings window
let createWindow = () => {
settingsWindow = new BrowserWindow({
width: 1200,
height: 700,
show: false,
fullscreenable: false,
maximizable: false,
minimizable: false,
webPreferences: {
nativeWindowOpen: true,
preload: path.join(__dirname, 'renderer/preload.js')
}
})
settingsWindow.setMenu(null)
settingsWindow.loadFile(path.join(__dirname, 'renderer/settings.html'))
settingsWindow.show()
//settingsWindow.openDevTools()
settingsWindow.on('will-resize', (e) => {
e.preventDefault();
});
ipcMain.on('close', (event) => {
settingsWindow.destroy()
});
}
if (settingsWindow === null) {
createWindow()
} else {
if (settingsWindow.isDestroyed() === true) {
createWindow()
} else {
settingsWindow.focus()
}
}
}
},
{
type: 'separator',
},
{
label: 'Quit',
click: () => {
app.exit()
}
},
])
tray.setToolTip('Electron Template')
tray.setContextMenu(contextMenu)
}
app.on('ready', boot)