This commit is contained in:
2024-07-01 16:50:17 +08:00
parent 7080571a6f
commit b5d30c67b9
5 changed files with 62 additions and 29 deletions
+6 -1
View File
@@ -1,7 +1,10 @@
const { Menu, BrowserWindow } = require("electron")
const path = require('node:path')
const server = require('../server/server');
const mainWin = require('../windows/app');
const iconPath = path.join(__dirname, '..', 'iyuu.ico')
let template = [
{
label: "IYUU",
@@ -15,7 +18,6 @@ let template = [
{
label: "重启服务",
click: () => {
mainWin.closeWindows()
server.restartServer()
}
@@ -26,6 +28,7 @@ let template = [
let win = new BrowserWindow({
width: 800,
height: 600,
icon: iconPath,
webPreferences: {
nodeIntegration: true,
contextIsolation: false,
@@ -48,6 +51,7 @@ let template = [
let win = new BrowserWindow({
width: 800,
height: 600,
icon: iconPath,
webPreferences: {
nodeIntegration: true,
contextIsolation: false,
@@ -65,6 +69,7 @@ let template = [
let win = new BrowserWindow({
width: 800,
height: 600,
icon: iconPath,
webPreferences: {
nodeIntegration: true,
contextIsolation: false,
+17 -3
View File
@@ -1,9 +1,11 @@
const { app, Menu, Tray } = require("electron")
const path = require('node:path')
const log = require('electron-log')
const server = require('../server/server');
const mainWin = require('../windows/app');
const tray = new Tray('iyuu.ico');
const iconPath = path.join(__dirname, '..', 'iyuu.ico')
const tray = new Tray(iconPath);
const contextMenu = Menu.buildFromTemplate([
{
@@ -12,12 +14,24 @@ const contextMenu = Menu.buildFromTemplate([
mainWin.showWindows()
}
},
{
label: '通过浏览器打开',
click: () => {
require('electron').shell.openExternal('http://127.0.0.1:8787')
}
},
{
label: '重启服务',
click: () => {
server.restartServer()
}
},
{
label: '强制退出',
click: () => {
app.exit(414)
}
},
{
label: '退出',
click: () => {
@@ -31,8 +45,8 @@ tray.setContextMenu(contextMenu);
tray.on('double-click', () => {
if (mainWin.visibleWindows()) {
mainWin.showWindows()
} else {
mainWin.hideWindows()
} else {
mainWin.showWindows()
}
});