Skip to content

Commit fe82fa6

Browse files
committed
fix: dev.mjs linux/macOS 设置 UTF-8
1 parent 28b521a commit fe82fa6

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

scripts/dev.mjs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,18 @@ if (isWindows) {
3939
} else {
4040
// macOS 和 Linux 环境
4141
console.log(`🐧 ${isMacOS ? "macOS" : "Linux"} 环境 - 正在设置 UTF-8 编码`);
42-
env.LC_ALL = "en_US.UTF-8";
43-
env.LANG = "en_US.UTF-8";
42+
const langVar = env.LC_ALL || env.LANG;
43+
if (langVar.endsWith("UTF-8")) {
44+
console.log("✅ 当前环境已设置 UTF-8 编码");
45+
} else {
46+
if (langVar.startsWith("zh_CN")) {
47+
env.LC_ALL = "zh_CN.UTF-8";
48+
env.LANG = "zh_CN.UTF-8";
49+
} else {
50+
env.LC_ALL = "en_US.UTF-8";
51+
env.LANG = "en_US.UTF-8";
52+
}
53+
}
4454
setTimeout(() => startElectronVite(), 0);
4555
}
4656

0 commit comments

Comments
 (0)