-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathelectron.js
56 lines (46 loc) · 1.21 KB
/
electron.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
import { app, BrowserWindow, Tray, Menu } from "electron";
import path from "path";
import isDev from "electron-is-dev";
let mainWindow;
async function createWindow() {
mainWindow = new BrowserWindow({
width: 1511, //
height: 1196,
titleBarStyle: "hiddenInset",
trafficLightPosition: {
y: "60"
},
webPreferences: {
nodeIntegration: true,
webviewTag: true,
devTools: true
},
});
const startURL = isDev
? "http://localhost:5173"
: `file://${path.join(__dirname, "../dist/index.html")}`;
await mainWindow.loadURL(startURL);
mainWindow.on("closed", () => {
console.log(mainWindow.width)
console.log(mainWindow.height)
mainWindow = null
});
}
app.on("ready", createWindow);
let tray = null
app.whenReady().then(() => {
tray = new Tray('/path/to/my/icon')
const contextMenu = Menu.buildFromTemplate([
{ label: 'Item1', type: 'radio' },
{ label: 'Item2', type: 'radio' },
{ label: 'Item3', type: 'radio', checked: true },
{ label: 'Item4', type: 'radio' }
])
tray.setToolTip('This is my application.')
tray.setContextMenu(contextMenu)
})
app.on("activate", () => {
if (mainWindow === null) {
createWindow();
}
});