系统托盘

This commit is contained in:
2024-06-29 00:41:06 +08:00
parent 7d2e569fd8
commit 0982fdd16e
6 changed files with 126 additions and 33 deletions
+27 -16
View File
@@ -5,6 +5,14 @@ let template = [
{
label: "IYUU",
submenu: [
{
label: "刷新",
click: () => {
BrowserWindow.getAllWindows().forEach(win => {
win.reload()
})
}
},
{
label: "重启服务",
click: () => {
@@ -13,7 +21,7 @@ let template = [
BrowserWindow.getAllWindows().forEach(win => {
win.reload()
})
}, 1000)
}, 2000)
}
},
@@ -39,6 +47,23 @@ let template = [
{
label: "帮助",
submenu: [
{
label: "问题反馈",
click: () => {
let win = new BrowserWindow({
width: 800,
height: 600,
webPreferences: {
nodeIntegration: true,
contextIsolation: false,
}
});
win.loadURL("https://gitee.com/qyg2297248353/iyuuplus-windows/issues");
win.on("closed", () => {
win = null;
});
}
},
{
label: "新疆萌森软件开发工作室提供技术支持",
click: () => {
@@ -57,21 +82,7 @@ let template = [
}
},
{
label: "问题反馈",
click: () => {
let win = new BrowserWindow({
width: 800,
height: 600,
webPreferences: {
nodeIntegration: true,
contextIsolation: false,
}
});
win.loadURL("https://gitee.com/qyg2297248353/iyuuplus-windows/issues");
win.on("closed", () => {
win = null;
});
}
label: "关于"
}
]
}
+43
View File
@@ -0,0 +1,43 @@
const { app, Menu, Tray, BrowserWindow } = require("electron")
const path = require('node:path')
const server = require('../server/server');
const tray = new Tray('iyuu.ico');
const contextMenu = Menu.buildFromTemplate([{
label: '打开主窗口',
click: () => {
BrowserWindow.getAllWindows().forEach(win => {
win.show()
})
}
}, {
label: '重启服务',
click: () => {
BrowserWindow.getAllWindows().forEach(win => {
win.hide()
})
server.restartServer()
setTimeout(() => {
BrowserWindow.getAllWindows().forEach(win => {
win.show()
win.reload()
})
}, 1000)
}
},
{
label: '退出',
click: () => {
app.quit()
}
}
]);
tray.setToolTip('IYUU');
tray.setContextMenu(contextMenu);
tray.on('double-click', () => {
win.isVisible() ? win.hide() : win.show()
win.isVisible() ? win.setSkipTaskbar(false) : win.setSkipTaskbar(true);
});