Update package.json and afterPack.js to set application name and version info, enhancing build process and user experience. Enable executable signing in package.json and improve logging in afterPack.js for better clarity during icon and version setting.
This commit is contained in:
parent
11ad2cf722
commit
982a51ef52
@ -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);
|
||||
// 不阻止打包继续
|
||||
}
|
||||
};
|
||||
|
||||
@ -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();
|
||||
|
||||
|
||||
@ -75,8 +75,9 @@
|
||||
}
|
||||
],
|
||||
"icon": "build/icon.ico",
|
||||
"executableName": "PHPer开发环境管理器",
|
||||
"requestedExecutionLevel": "requireAdministrator",
|
||||
"signAndEditExecutable": false
|
||||
"signAndEditExecutable": true
|
||||
},
|
||||
"nsis": {
|
||||
"oneClick": false,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user