mirror of
https://gitee.com/hhyykk/ipms-sjy.git
synced 2025-07-13 18:45:06 +08:00
feat: add vue3(element-plus)
This commit is contained in:
35
yudao-ui-admin-vue3/src/store/modules/locale.ts
Normal file
35
yudao-ui-admin-vue3/src/store/modules/locale.ts
Normal file
@ -0,0 +1,35 @@
|
||||
import { defineStore } from 'pinia'
|
||||
import { store } from '../index'
|
||||
import { useCache } from '@/hooks/web/useCache'
|
||||
import { localeModules, elLocaleMap } from '@/config/locale'
|
||||
import type { LocaleState } from '@/config/locale'
|
||||
|
||||
const { wsCache } = useCache()
|
||||
|
||||
export const useLocaleStore = defineStore({
|
||||
id: 'locales',
|
||||
state: (): LocaleState => localeModules,
|
||||
persist: {
|
||||
enabled: true
|
||||
},
|
||||
getters: {
|
||||
getCurrentLocale(): LocaleDropdownType {
|
||||
return this.currentLocale
|
||||
},
|
||||
getLocaleMap(): LocaleDropdownType[] {
|
||||
return this.localeMap
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
setCurrentLocale(localeMap: LocaleDropdownType) {
|
||||
// this.locale = Object.assign(this.locale, localeMap)
|
||||
this.currentLocale.lang = localeMap?.lang
|
||||
this.currentLocale.elLocale = elLocaleMap[localeMap?.lang]
|
||||
wsCache.set('lang', localeMap?.lang)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
export const useLocaleStoreWithOut = () => {
|
||||
return useLocaleStore(store)
|
||||
}
|
Reference in New Issue
Block a user