fix: 处理切换语言,UI框架不会变的问题

This commit is contained in:
奔跑的面条
2022-11-05 15:23:01 +08:00
parent f6a4e87e05
commit afed1cb6b3
6 changed files with 52 additions and 12 deletions
+3 -3
View File
@@ -1,10 +1,10 @@
import type { App } from 'vue';
import { createPinia } from 'pinia';
const store = createPinia();
const pinia = createPinia();
export function setupStore(app: App<Element>) {
app.use(store);
app.use(pinia);
}
export { store };
export { pinia };
+3 -3
View File
@@ -6,10 +6,8 @@ import i18n from '@/i18n/index'
import { setLocalStorage, getLocalStorage, reloadRoutePage } from '@/utils'
import { StorageEnum } from '@/enums/storageEnum'
import { useSettingStore } from '@/store/modules/settingStore/settingStore'
const settingStore = useSettingStore()
const { GO_LANG_STORE } = StorageEnum
const storageLang: LangStateType = getLocalStorage(GO_LANG_STORE)
// 语言
@@ -17,7 +15,7 @@ export const useLangStore = defineStore({
id: 'useLangStore',
state: (): LangStateType =>
storageLang || {
lang,
lang
},
getters: {
getLang(): LangEnum {
@@ -26,6 +24,8 @@ export const useLangStore = defineStore({
},
actions: {
changeLang(lang: LangEnum): void {
const settingStore = useSettingStore()
if (this.lang === lang) return
this.lang = lang
i18n.global.locale = lang