From 5ee6ee75f157481997d0a4e9b0f10f971522da02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=A2=81=E6=B6=9B?= Date: Fri, 17 Apr 2026 23:42:20 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20=E6=89=93=E5=8C=85?= =?UTF-8?q?=E5=90=8E=E6=89=98=E7=9B=98=E5=9B=BE=E6=A0=87=E4=B8=8D=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.js | 10 ++++++++-- package.json | 6 ++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/main.js b/main.js index 9f6369a..6b57f35 100644 --- a/main.js +++ b/main.js @@ -11,8 +11,14 @@ const isDev = process.argv.includes('--dev') // 创建系统托盘 function createTray() { - // 使用内置图标或创建空白图标 - const iconPath = path.join(__dirname, 'build', 'icon.ico') + // 获取图标路径 - 打包后需要从 extraResources 获取 + let iconPath + if (app.isPackaged) { + iconPath = path.join(process.resourcesPath, 'icon', 'icon.ico') + } else { + iconPath = path.join(__dirname, 'build', 'icon.ico') + } + let trayIcon if (fs.existsSync(iconPath)) { trayIcon = nativeImage.createFromPath(iconPath) diff --git a/package.json b/package.json index 1c4c6c9..af114ec 100644 --- a/package.json +++ b/package.json @@ -30,6 +30,12 @@ "output": "release", "buildResources": "build" }, + "extraResources": [ + { + "from": "build/icon.ico", + "to": "icon/icon.ico" + } + ], "files": [ "dist/**/*", "main.js",