-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
60 lines (46 loc) · 1.33 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
const { app, BrowserWindow, Tray, Menu, screen, ipcMain } = require('electron')
const path = require('node:path')
const createWindow = () => {
const primaryDisplay = screen.getPrimaryDisplay()
const { width, height } = primaryDisplay.workAreaSize
const win = new BrowserWindow({
width: 570,
height: 800,
x : width - 540,
y : 0,
frame : false,
skipTaskbar : false,
transparent : true,
webPreferences : {
preload : path.join(__dirname, 'preload.js')
},
icon : path.join(__dirname, 'head.png')
})
ipcMain.handle('resize-window', function() {
win.loadFile('pages/fullscreen.html')
win.setSize(width, height)
win.setPosition(0, 0)
})
win.loadFile('pages/index.html')
win.on('minimize', (event) => {
event.preventDefault();
win.minimize();
});
}
app.whenReady().then(() => {
appIcon = new Tray('resources/tray.png')
const contextMenu = Menu.buildFromTemplate([
{
label: 'Open',
type: 'normal',
click : createWindow
},
{
label: 'Exit',
type: 'normal',
click: () => app.exit()
}
])
contextMenu.items[1].checked = false
appIcon.setContextMenu(contextMenu)
})