mirror of
https://github.com/QYG2297248353/IYUUPlus-Windows.git
synced 2025-12-29 08:01:35 +08:00
系统托盘
This commit is contained in:
+27
-16
@@ -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: "关于"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
Reference in New Issue
Block a user