diff --git a/src/components/AppProvider.vue b/src/components/AppProvider.vue
index ac514fe..0a5ef6f 100644
--- a/src/components/AppProvider.vue
+++ b/src/components/AppProvider.vue
@@ -44,11 +44,11 @@ const getTheme = computed(() => {
});
const locale = computed(() => {
- let langType = appStore.languageType;
+ let langType = appStore.languageName;
return langType === 'zhCN' ? zhCN : enUS;
});
const dateLocale = computed(() => {
- let langType = appStore.languageType;
+ let langType = appStore.languageName;
return langType === 'zhCN' ? dateZhCN : dateEnUS;
});
const NaiveProviderContent = defineComponent({
diff --git a/src/store/appStore.ts b/src/store/appStore.ts
index aafa72b..0608432 100644
--- a/src/store/appStore.ts
+++ b/src/store/appStore.ts
@@ -3,7 +3,8 @@ export const useAppStore = defineStore('app', {
state() {
return {
themeType: 0, // 0 auto, 1: dark, 2: light
- languageType: 'zhCN', // zhCN || enUS
+ languageType: 'auto', // 0: auto, 1: zhCN, 2: enUS
+ languageName: 'zhCN', // zhCN || enUS
};
},
actions: {
@@ -14,6 +15,11 @@ export const useAppStore = defineStore('app', {
setLanguageType(args: string) {
this.languageType = args;
localStorage.setItem('lang', String(args));
+ if (args === 'auto') {
+ this.languageName = navigator.language === 'zh-CN' ? 'zhCN' : 'enUS';
+ } else {
+ this.languageName = args;
+ }
},
},
});
diff --git a/src/views/editor/index.vue b/src/views/editor/index.vue
index d894af2..08f4d17 100644
--- a/src/views/editor/index.vue
+++ b/src/views/editor/index.vue
@@ -1,10 +1,10 @@
-
+
-
diff --git a/src/views/setting/components/basic.vue b/src/views/setting/components/basic.vue
index bce7783..43f2170 100644
--- a/src/views/setting/components/basic.vue
+++ b/src/views/setting/components/basic.vue
@@ -83,11 +83,8 @@ const setThemeType = (type: number) => {
const langTypeChange = (value: string) => {
langType.value = value;
- if (value === 'auto') {
- value = navigator.language === 'zh-CN' ? 'zhCN' : 'enUS';
- }
appStore.setLanguageType(value);
- lang.global.locale.value = value;
+ lang.global.locale.value = appStore.languageName;
};