Skip to content

Commit 0d1d377

Browse files
committed
fix: build
1 parent d5bfc42 commit 0d1d377

1 file changed

Lines changed: 10 additions & 8 deletions

File tree

scripts/afterPack.js

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,24 @@
22
const fs = require('fs');
33
const path = require('path');
44

5-
module.exports = async function(context) {
5+
module.exports = async function (context) {
66
console.log('🗑️ Removing unused language packs...');
77

88
const appOutDir = context.appOutDir;
99
const electronPath = context.electronPlatformName === 'darwin'
1010
? path.join(appOutDir, `${context.packager.appInfo.productFilename}.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Resources`)
1111
: path.join(appOutDir, 'locales');
1212

13-
// 只保留英文
14-
const keepLanguages = ['en.lproj', 'en_US.pak'];
13+
// 保留英文和中文
14+
const keepLanguages = ['en.lproj', 'en-US.pak', 'zh-TW.pak', 'zh-CN.pak'];
1515

1616
try {
1717
if (context.electronPlatformName === 'darwin') {
1818
// macOS: 刪除 .lproj 目錄
1919
const files = fs.readdirSync(electronPath);
2020
let removed = 0;
2121

22-
files.forEach(file => {
22+
files.forEach((file) => {
2323
if (file.endsWith('.lproj') && !keepLanguages.includes(file)) {
2424
const fullPath = path.join(electronPath, file);
2525
fs.rmSync(fullPath, { recursive: true, force: true });
@@ -28,12 +28,13 @@ module.exports = async function(context) {
2828
});
2929

3030
console.log(`✅ Removed ${removed} language packs from macOS`);
31-
} else {
31+
}
32+
else {
3233
// Windows/Linux: 刪除 .pak 檔案
3334
const files = fs.readdirSync(electronPath);
3435
let removed = 0;
3536

36-
files.forEach(file => {
37+
files.forEach((file) => {
3738
if (file.endsWith('.pak') && !keepLanguages.includes(file)) {
3839
const fullPath = path.join(electronPath, file);
3940
fs.unlinkSync(fullPath);
@@ -43,7 +44,8 @@ module.exports = async function(context) {
4344

4445
console.log(`✅ Removed ${removed} language packs from ${context.electronPlatformName}`);
4546
}
46-
} catch (err) {
47+
}
48+
catch (err) {
4749
console.error('⚠️ Error removing language packs:', err.message);
4850
}
49-
};
51+
};

0 commit comments

Comments
 (0)