-
Notifications
You must be signed in to change notification settings - Fork 199
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
35fd5ae
commit 7506d04
Showing
12 changed files
with
78 additions
and
286 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
const fs = require('fs') | ||
const path = require('path') | ||
|
||
exports.default = async function (context) { | ||
const platform = context.packager.platform.name | ||
|
||
// 根据平台确定 locales 目录位置 | ||
let resourceDirs = [] | ||
if (platform === 'mac') { | ||
// macOS 的语言文件位置 | ||
resourceDirs = [ | ||
path.join(context.appOutDir, 'Cherry Studio.app', 'Contents', 'Resources'), | ||
path.join( | ||
context.appOutDir, | ||
'Cherry Studio.app', | ||
'Contents', | ||
'Frameworks', | ||
'Electron Framework.framework', | ||
'Resources' | ||
) | ||
] | ||
} else { | ||
// Windows 和 Linux 的语言文件位置 | ||
resourceDirs = [path.join(context.appOutDir, 'locales')] | ||
} | ||
|
||
// 处理每个资源目录 | ||
for (const resourceDir of resourceDirs) { | ||
if (!fs.existsSync(resourceDir)) { | ||
console.log(`Resource directory not found: ${resourceDir}, skipping...`) | ||
continue | ||
} | ||
|
||
// 读取所有文件和目录 | ||
const items = fs.readdirSync(resourceDir) | ||
|
||
// 遍历并删除不需要的语言文件 | ||
for (const item of items) { | ||
if (platform === 'mac') { | ||
// 在 macOS 上检查 .lproj 目录 | ||
if (item.endsWith('.lproj') && !item.match(/^(en|zh|ru)/)) { | ||
const dirPath = path.join(resourceDir, item) | ||
fs.rmSync(dirPath, { recursive: true, force: true }) | ||
console.log(`Removed locale directory: ${item} from ${resourceDir}`) | ||
} | ||
} else { | ||
// 其他平台处理 .pak 文件 | ||
if (!item.match(/^(en|zh|ru)/)) { | ||
const filePath = path.join(resourceDir, item) | ||
fs.unlinkSync(filePath) | ||
console.log(`Removed locale file: ${item} from ${resourceDir}`) | ||
} | ||
} | ||
} | ||
} | ||
|
||
console.log('Locale cleanup completed!') | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.