1234567891011121314151617181920212223242526272829303132333435363738394041 |
- import { defineStore } from 'pinia'
- import { en, zhHans } from 'vuetify/locale'
- import { reactive } from 'vue'
- const elLocaleMap = {
- 'zh-CN': zhHans,
- en: en
- }
- export const useLocaleStore = defineStore('locales',
- () => {
- const localeMap = [
- {
- lang: 'zh-CN',
- name: '简体中文'
- },
- {
- lang: 'en',
- name: 'English'
- }
- ]
- const currentLocale = reactive({
- lang: 'zh-CN',
- elLocale: elLocaleMap['zh-CN']
- })
- const setCurrentLocale = (localeMap) => {
- // this.locale = Object.assign(this.locale, localeMap)
- currentLocale.lang = localeMap.lang
- currentLocale.elLocale = elLocaleMap[localeMap.lang]
- }
- return {
- localeMap,
- currentLocale,
- setCurrentLocale
- }
- },
- {
- persist: true, // ref() 持久化响应
- }
- )
|