mirror of
https://github.com/QYG2297248353/IYUUPlus-Windows.git
synced 2024-11-10 14:37:04 +08:00
43 lines
1013 B
JavaScript
43 lines
1013 B
JavaScript
|
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);
|
||
|
});
|