From 4ea7376dbc32374c03e60c131b5ce728762cff6b Mon Sep 17 00:00:00 2001 From: LiuHao <liuhaoai545@gmail.com> Date: 星期四, 11 一月 2024 15:26:37 +0800 Subject: [PATCH] fix 修复i18n无感刷新问题 --- src/lang/index.ts | 1 + vite.config.ts | 3 +-- src/layout/components/Navbar.vue | 2 +- src/components/LangSelect/index.vue | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/components/LangSelect/index.vue b/src/components/LangSelect/index.vue index f5ae8e8..b5fafd3 100644 --- a/src/components/LangSelect/index.vue +++ b/src/components/LangSelect/index.vue @@ -14,8 +14,8 @@ <script setup lang="ts"> import { useI18n } from 'vue-i18n'; -import SvgIcon from '@/components/SvgIcon/index.vue'; import { useAppStore } from '@/store/modules/app'; +import SvgIcon from '@/components/SvgIcon/index.vue'; const appStore = useAppStore(); const { locale } = useI18n(); @@ -24,7 +24,7 @@ zh_CN: '鍒囨崲璇█鎴愬姛锛�', en_US: 'Switch Language Successful!' }; -const handleLanguageChange = (lang: string) => { +const handleLanguageChange = (lang: any) => { locale.value = lang; appStore.changeLanguage(lang); ElMessage.success(message[lang] || '鍒囨崲璇█鎴愬姛锛�'); diff --git a/src/lang/index.ts b/src/lang/index.ts index 2b4c027..e4e1d25 100644 --- a/src/lang/index.ts +++ b/src/lang/index.ts @@ -18,6 +18,7 @@ const i18n = createI18n({ globalInjection: true, + allowComposition: true, legacy: false, locale: getLanguage(), messages diff --git a/src/layout/components/Navbar.vue b/src/layout/components/Navbar.vue index 49018ce..5225cdc 100644 --- a/src/layout/components/Navbar.vue +++ b/src/layout/components/Navbar.vue @@ -92,11 +92,11 @@ import useAppStore from '@/store/modules/app'; import useUserStore from '@/store/modules/user'; import useSettingsStore from '@/store/modules/settings'; +import useNoticeStore from '@/store/modules/notice'; import { getTenantList } from '@/api/login'; import { dynamicClear, dynamicTenant } from '@/api/system/tenant'; import { TenantVO } from '@/api/types'; import notice from './notice/index.vue'; -import useNoticeStore from '@/store/modules/notice'; const appStore = useAppStore(); const userStore = useUserStore(); diff --git a/vite.config.ts b/vite.config.ts index e323dc7..01da668 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -13,8 +13,7 @@ resolve: { alias: { '~': path.resolve(__dirname, './'), - '@': path.resolve(__dirname, './src'), - 'vue-i18n': 'vue-i18n/dist/vue-i18n.cjs.js' + '@': path.resolve(__dirname, './src') }, extensions: ['.mjs', '.js', '.ts', '.jsx', '.tsx', '.json', '.vue'] }, -- Gitblit v1.9.3