mirror of
https://gitee.com/dromara/go-view.git
synced 2026-04-23 00:00:12 +08:00
fix: 抽离全局设置的位置
This commit is contained in:
-2
@@ -2,6 +2,4 @@ import { LangEnum } from '@/enums/styleEnum'
|
||||
export interface LangStateType {
|
||||
// 当前语言
|
||||
lang: LangEnum,
|
||||
// 是否刷新
|
||||
isReload: boolean
|
||||
}
|
||||
|
||||
@@ -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()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user