You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
834 B
TypeScript

import { defineStore } from 'pinia'
import { store } from '../index'
import { localeModules, elLocaleMap } from '@/config/locale'
import type { LocaleState } from '@/config/locale'
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]
}
}
})
export const useLocaleStoreWithOut = () => {
return useLocaleStore(store)
}