From c09fd7ba0063d6fb169a9f4e5bbfc4c3409f3c1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E8=AF=BA?= <1253070437@qq.com> Date: Wed, 4 Oct 2023 01:31:32 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E6=9B=B4=E6=96=B0=E3=80=91=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E5=A4=9A=E8=AF=AD=E7=A7=8D=E5=B0=8F=E7=91=95=E7=96=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- snowy-admin-web/src/App.vue | 2 +- snowy-admin-web/src/layout/components/userbar.vue | 5 +++-- snowy-admin-web/src/locales/index.js | 1 + 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/snowy-admin-web/src/App.vue b/snowy-admin-web/src/App.vue index 9fbe1c78..d9439db4 100644 --- a/snowy-admin-web/src/App.vue +++ b/snowy-admin-web/src/App.vue @@ -10,5 +10,5 @@ const store = globalStore() store.initTheme() - const locale = i18n.global.messages[i18n.global.locale].lang + const locale = i18n.global.messages.value[i18n.global.locale.value].lang diff --git a/snowy-admin-web/src/layout/components/userbar.vue b/snowy-admin-web/src/layout/components/userbar.vue index ba2b046e..4197622d 100644 --- a/snowy-admin-web/src/layout/components/userbar.vue +++ b/snowy-admin-web/src/layout/components/userbar.vue @@ -57,7 +57,6 @@ import { createVNode } from 'vue' import { ExclamationCircleOutlined } from '@ant-design/icons-vue' import { Modal } from 'ant-design-vue' - import i18n from '@/locales/index' import screenFull from 'screenfull' import { message } from 'ant-design-vue' import Setting from './setting.vue' @@ -68,6 +67,8 @@ import DevUserMessage from './message.vue' import PanelSearch from './panel-search/index.vue' import { globalStore } from '@/store' + import { useI18n } from 'vue-i18n' + const { locale } = useI18n() const lang = ref(new Array(tool.data.get('APP_LANG') || config.LANG)) const settingDialog = ref(false) @@ -142,7 +143,7 @@ const handleIn18 = (key) => { lang.value = [] lang.value.push(key) - i18n.locale = key + locale.value = key tool.data.set('APP_LANG', key) } // 设置抽屉 diff --git a/snowy-admin-web/src/locales/index.js b/snowy-admin-web/src/locales/index.js index ab3f23cc..08e82b99 100644 --- a/snowy-admin-web/src/locales/index.js +++ b/snowy-admin-web/src/locales/index.js @@ -28,6 +28,7 @@ export const messages = { } const i18n = createI18n({ + legacy: false, locale: tool.data.get('APP_LANG') || sysConfig.LANG, fallbackLocale: 'zh-cn', globalInjection: true,