mirror of
https://github.com/dream-pep/koring-launcher.git
synced 2026-09-12 05:45:18 +08:00
fix(switch-icon脚本): 适配脚本以支持跨平台打包
添加平台检测逻辑,仅在Windows平台处理NSIS安装器所需的专属资源,Linux平台仅复制必要的图标文件,同时更新日志输出以正确显示已生成的文件。
This commit is contained in:
File diff suppressed because one or more lines are too long
+30
-14
@@ -31,6 +31,10 @@ if (!mode || !validModes.includes(mode)) {
|
|||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NSIS 专属资源(ico / 侧边横幅 BMP / 自定义脚本 / license)仅 Windows 打包需要;
|
||||||
|
// Linux(AppImage 等)只需 build/icon.png,且不能调用 PowerShell。
|
||||||
|
const isWin = process.platform === 'win32';
|
||||||
|
|
||||||
const root = join(__dirname, '..');
|
const root = join(__dirname, '..');
|
||||||
const srcDir = join(root, 'public', 'icons', mode);
|
const srcDir = join(root, 'public', 'icons', mode);
|
||||||
const buildDir = join(root, 'build');
|
const buildDir = join(root, 'build');
|
||||||
@@ -45,13 +49,17 @@ const licenseSrc = join(
|
|||||||
mode === 'beta' ? 'protocol-beta.txt' : 'protocol-user.txt'
|
mode === 'beta' ? 'protocol-beta.txt' : 'protocol-user.txt'
|
||||||
);
|
);
|
||||||
|
|
||||||
// 必选文件存在性检查
|
// 必选文件存在性检查(Windows 全量;Linux 仅 icon.png)
|
||||||
const requiredFiles = [
|
const requiredFiles = [
|
||||||
{ path: png, label: 'icon.png' },
|
{ path: png, label: 'icon.png' },
|
||||||
{ path: ico, label: 'icon.ico' },
|
...(isWin
|
||||||
{ path: installerHeader, label: 'installer-header.png' },
|
? [
|
||||||
{ path: nsisCustom, label: 'installer-custom.nsh' },
|
{ path: ico, label: 'icon.ico' },
|
||||||
{ path: licenseSrc, label: 'license 协议文件' },
|
{ path: installerHeader, label: 'installer-header.png' },
|
||||||
|
{ path: nsisCustom, label: 'installer-custom.nsh' },
|
||||||
|
{ path: licenseSrc, label: 'license 协议文件' },
|
||||||
|
]
|
||||||
|
: []),
|
||||||
];
|
];
|
||||||
for (const file of requiredFiles) {
|
for (const file of requiredFiles) {
|
||||||
if (!existsSync(file.path)) {
|
if (!existsSync(file.path)) {
|
||||||
@@ -112,19 +120,27 @@ function writeLicenseWithBom(src, out) {
|
|||||||
|
|
||||||
mkdirSync(buildDir, { recursive: true });
|
mkdirSync(buildDir, { recursive: true });
|
||||||
|
|
||||||
// 1. 图标
|
// 1. 图标(各平台通用:AppImage / Linux 需要 build/icon.png)
|
||||||
cpSync(png, join(buildDir, 'icon.png'), { overwrite: true });
|
cpSync(png, join(buildDir, 'icon.png'), { overwrite: true });
|
||||||
cpSync(ico, join(buildDir, 'icon.ico'), { overwrite: true });
|
|
||||||
|
|
||||||
// 2. 安装程序欢迎页左侧大图(installerSidebar,由横幅 PNG 适配生成)
|
// Windows 专属:NSIS 安装器资源
|
||||||
createSidebarBmp(installerHeader, join(buildDir, 'installer-header.bmp'));
|
if (isWin) {
|
||||||
|
cpSync(ico, join(buildDir, 'icon.ico'), { overwrite: true });
|
||||||
|
|
||||||
// 3. NSIS 自定义脚本
|
// 2. 安装程序欢迎页左侧大图(installerSidebar,由横幅 PNG 适配生成)
|
||||||
cpSync(nsisCustom, join(buildDir, 'installer-custom.nsh'), { overwrite: true });
|
createSidebarBmp(installerHeader, join(buildDir, 'installer-header.bmp'));
|
||||||
|
|
||||||
// 4. 协议文件(带 UTF-8 BOM,防止中文乱码)
|
// 3. NSIS 自定义脚本
|
||||||
writeLicenseWithBom(licenseSrc, join(buildDir, 'license.txt'));
|
cpSync(nsisCustom, join(buildDir, 'installer-custom.nsh'), { overwrite: true });
|
||||||
|
|
||||||
|
// 4. 协议文件(带 UTF-8 BOM,防止中文乱码)
|
||||||
|
writeLicenseWithBom(licenseSrc, join(buildDir, 'license.txt'));
|
||||||
|
}
|
||||||
|
|
||||||
console.log(
|
console.log(
|
||||||
`[switch-icon] Mode: ${mode} → build/icon.png + build/icon.ico + build/installer-header.bmp (sidebar 164x314) + build/installer-custom.nsh + build/license.txt updated`
|
`[switch-icon] Mode: ${mode} → build/icon.png` +
|
||||||
|
(isWin
|
||||||
|
? ' + build/icon.ico + build/installer-header.bmp (sidebar 164x314) + build/installer-custom.nsh + build/license.txt'
|
||||||
|
: '(Linux:仅 icon.png)') +
|
||||||
|
' updated'
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user