fix: 抽离全局设置的位置

This commit is contained in:
mtruning
2022-01-15 16:07:46 +08:00
parent 3758db4cb6
commit 551a1f2d01
12 changed files with 46 additions and 59 deletions
-2
View File
@@ -2,6 +2,4 @@ import { LangEnum } from '@/enums/styleEnum'
export interface LangStateType {
// 当前语言
lang: LangEnum,
// 是否刷新
isReload: boolean
}
+3 -10
View File
@@ -5,6 +5,8 @@ import { LangEnum } from '@/enums/styleEnum'
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
@@ -16,29 +18,20 @@ export const useLangStore = defineStore({
state: (): LangStateType =>
storageLang || {
lang,
isReload: false
},
getters: {
getLang(): LangEnum {
return this.lang
},
getReload(): boolean {
return this.isReload
}
},
actions: {
changeReload(value: boolean): void {
this.isReload = value
setLocalStorage(GO_LANG_STORE, this.$state)
},
changeLang(lang: LangEnum): void {
if (this.lang === lang) return
this.lang = lang
i18n.global.locale = lang
setLocalStorage(GO_LANG_STORE, this.$state)
if (this.getReload) {
if (settingStore.getChangeLangReload) {
reloadRoutePage()
}
}