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",