Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 2 additions & 11 deletions packages/traction-widget/components/hooks/useLocale.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,14 @@
import { ref } from 'vue';
import zhCN from '../locales/lang/zhCN.ts';
import enUS from '../locales/lang/enUS.ts';

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

export function useLocale (): Locale {
const locale = ref<Locale>({});
let storedLocale = 'zh-CN'; // 默认使用中文

// 只在浏览器环境下读取 localStorage
let storedLocale = 'zh-CN';
if (typeof window !== 'undefined') {
storedLocale = localStorage.getItem('fes_locale') || 'zh-CN';
}

if (storedLocale === 'en-US') {
locale.value = enUS;
} else {
locale.value = zhCN;
}
return locale.value;
return storedLocale === 'en-US' ? enUS : zhCN;
}
Loading