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,