From 345cc3d9553ff42349f6aa843a8795f688e1df84 Mon Sep 17 00:00:00 2001 From: zhengkunwang223 Date: Thu, 16 Feb 2023 11:24:24 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=A7=A3=E5=86=B3=E5=88=B7=E6=96=B0?= =?UTF-8?q?=E4=B9=8B=E5=90=8E=E8=8E=B7=E5=8F=96=E4=B8=8D=E5=88=B0=20i18n?= =?UTF-8?q?=20=E9=85=8D=E7=BD=AE=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/App.vue | 2 -- frontend/src/lang/index.ts | 2 +- frontend/src/store/index.ts | 1 + frontend/src/views/website/website/index.vue | 3 ++- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/frontend/src/App.vue b/frontend/src/App.vue index 6060971d9..a6c7b18ef 100644 --- a/frontend/src/App.vue +++ b/frontend/src/App.vue @@ -23,8 +23,6 @@ const i18nLocale = computed((): any => { return ''; }); -// const assemblySize = computed((): string => globalStore.assemblySize); - let isRouterAlive = ref(true); const reload = () => { diff --git a/frontend/src/lang/index.ts b/frontend/src/lang/index.ts index 4603ef6ba..d4a3cdaa3 100644 --- a/frontend/src/lang/index.ts +++ b/frontend/src/lang/index.ts @@ -4,7 +4,7 @@ import en from './modules/en'; const i18n = createI18n({ legacy: false, - locale: 'zh', + locale: localStorage.getItem('lang') || 'zh', globalInjection: true, messages: { zh, diff --git a/frontend/src/store/index.ts b/frontend/src/store/index.ts index db133abdb..d4d480d36 100644 --- a/frontend/src/store/index.ts +++ b/frontend/src/store/index.ts @@ -40,6 +40,7 @@ export const GlobalStore = defineStore({ }, updateLanguage(language: any) { this.language = language; + localStorage.setItem('lang', language); }, setThemeConfig(themeConfig: ThemeConfigProp) { this.themeConfig = themeConfig; diff --git a/frontend/src/views/website/website/index.vue b/frontend/src/views/website/website/index.vue index d485b8d30..a1281b55d 100644 --- a/frontend/src/views/website/website/index.vue +++ b/frontend/src/views/website/website/index.vue @@ -166,10 +166,11 @@ import { App } from '@/api/interface/app'; import { ElMessageBox } from 'element-plus'; import { dateFormatSimple } from '@/utils/util'; import { MsgSuccess } from '@/utils/message'; +import { useI18n } from 'vue-i18n'; const shortcuts = [ { - text: i18n.global.t('website.ever'), + text: useI18n().t('website.ever'), value: () => { return new Date('1970-01-01'); },