修复在开发模式下没有正确加载托盘图标的问题

This commit is contained in:
Allen 2025-05-11 11:01:17 +08:00
parent 24cb194937
commit 66c3d6f948
2 changed files with 3 additions and 2 deletions

View File

@ -5,7 +5,7 @@
"description": "My Electron application description",
"main": ".vite/build/main.js",
"scripts": {
"start": "electron-forge start",
"start": "cross-env NODE_ENV=development electron-forge start",
"package": "electron-forge package",
"make": "electron-forge make",
"publish": "electron-forge publish",
@ -30,6 +30,7 @@
"@types/electron-squirrel-startup": "^1.0.2",
"@typescript-eslint/eslint-plugin": "^5.62.0",
"@typescript-eslint/parser": "^5.62.0",
"cross-env": "^7.0.3",
"electron": "36.0.0",
"eslint": "^8.57.1",
"eslint-plugin-import": "^2.31.0",

View File

@ -174,7 +174,7 @@ const createWindow = () => {
{ label: '显示窗口', click: () => win.show() },
{ label: '退出程序', click: () => app.exit() }
]);
const iconPath = path.join(process.resourcesPath, 'assets', 'tray.png');
const iconPath = process.env.NODE_ENV === 'development' ? path.join(__dirname, '../../assets/tray.png') : path.join(process.resourcesPath, 'assets', 'tray.png');
const tray = new Tray(iconPath);
tray.setToolTip('中国电信-工作台');
tray.setContextMenu(contextMenu);