From 66c3d6f94807292a40b4e888a5c28cb0b8dfdfb0 Mon Sep 17 00:00:00 2001 From: Allen Date: Sun, 11 May 2025 11:01:17 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=9C=A8=E5=BC=80=E5=8F=91?= =?UTF-8?q?=E6=A8=A1=E5=BC=8F=E4=B8=8B=E6=B2=A1=E6=9C=89=E6=AD=A3=E7=A1=AE?= =?UTF-8?q?=E5=8A=A0=E8=BD=BD=E6=89=98=E7=9B=98=E5=9B=BE=E6=A0=87=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 3 ++- src/main.ts | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index d011d15..aa60567 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/main.ts b/src/main.ts index 3d89c89..5067ebb 100644 --- a/src/main.ts +++ b/src/main.ts @@ -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);