diff --git a/build/afterPack.js b/build/afterPack.js index 7d70c64..090444e 100644 --- a/build/afterPack.js +++ b/build/afterPack.js @@ -7,10 +7,11 @@ exports.default = async function(context) { return; } - console.log('Running afterPack hook to set icon...'); + console.log('Running afterPack hook to set icon and version info...'); const appOutDir = context.appOutDir; const productName = context.packager.appInfo.productName; + const version = context.packager.appInfo.version; const exePath = path.join(appOutDir, `${productName}.exe`); const iconPath = path.join(__dirname, 'icon.ico'); @@ -25,18 +26,29 @@ exports.default = async function(context) { } try { - // 使用 npm 安装的 rcedit 模块 - const { rcedit } = require('rcedit'); + // rcedit 是默认导出 + const rcedit = require('rcedit'); - console.log(`Setting icon for: ${exePath}`); + console.log(`Setting icon and version info for: ${exePath}`); console.log(`Using icon: ${iconPath}`); await rcedit(exePath, { - icon: iconPath + icon: iconPath, + 'version-string': { + 'ProductName': productName, + 'FileDescription': productName, + 'CompanyName': 'PHPer', + 'LegalCopyright': 'Copyright © 2024 PHPer', + 'OriginalFilename': `${productName}.exe`, + 'InternalName': productName + }, + 'file-version': version, + 'product-version': version }); - console.log('Icon set successfully!'); + console.log('Icon and version info set successfully!'); } catch (error) { console.error('Failed to set icon:', error.message); + // 不阻止打包继续 } }; diff --git a/electron/main.ts b/electron/main.ts index d38a934..2903d14 100644 --- a/electron/main.ts +++ b/electron/main.ts @@ -241,6 +241,15 @@ function createTray() { }); } +// 设置应用名称和 Windows AppUserModelId(用于任务栏图标分组和进程名称显示) +const APP_NAME = "PHPer开发环境管理器"; +const APP_ID = "com.phper.devmanager"; + +app.setName(APP_NAME); +if (process.platform === "win32") { + app.setAppUserModelId(APP_ID); +} + // 单实例锁定 const gotTheLock = app.requestSingleInstanceLock(); diff --git a/package.json b/package.json index ecb1942..80a756f 100644 --- a/package.json +++ b/package.json @@ -75,8 +75,9 @@ } ], "icon": "build/icon.ico", + "executableName": "PHPer开发环境管理器", "requestedExecutionLevel": "requireAdministrator", - "signAndEditExecutable": false + "signAndEditExecutable": true }, "nsis": { "oneClick": false,