Skip to content

Commit 19848e7

Browse files
committed
fix: 删除useLocale的ref
1 parent 0d3bf2b commit 19848e7

File tree

1 file changed

+2
-11
lines changed

1 file changed

+2
-11
lines changed
Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,14 @@
1-
import { ref } from 'vue';
21
import zhCN from '../locales/lang/zhCN.ts';
32
import enUS from '../locales/lang/enUS.ts';
43

54
// 定义 locale 类型
65
type Locale = Record<string, any>;
76

87
export function useLocale (): Locale {
9-
const locale = ref<Locale>({});
10-
let storedLocale = 'zh-CN'; // 默认使用中文
11-
12-
// 只在浏览器环境下读取 localStorage
8+
let storedLocale = 'zh-CN';
139
if (typeof window !== 'undefined') {
1410
storedLocale = localStorage.getItem('fes_locale') || 'zh-CN';
1511
}
1612

17-
if (storedLocale === 'en-US') {
18-
locale.value = enUS;
19-
} else {
20-
locale.value = zhCN;
21-
}
22-
return locale.value;
13+
return storedLocale === 'en-US' ? enUS : zhCN;
2314
}

0 commit comments

Comments
 (0)