|
@@ -1,60 +0,0 @@
|
|
-import { defineStore } from 'pinia'
|
|
|
|
-import { store } from '../index'
|
|
|
|
-import { en, zhHans, zhHant } from 'vuetify/locale'
|
|
|
|
-import { getLang, setLang } from '@/utils/catch'
|
|
|
|
-// import zhCn from 'element-plus/es/locale/lang/zh-cn'
|
|
|
|
-// import en from 'element-plus/es/locale/lang/en'
|
|
|
|
-// import { CACHE_KEY, useCache } from '@/hooks/web/useCache'
|
|
|
|
-
|
|
|
|
-// const { wsCache } = useCache()
|
|
|
|
-
|
|
|
|
-const elLocaleMap = {
|
|
|
|
- 'zh-CN-Hant': zhHant,
|
|
|
|
- 'zh-CN': zhHans,
|
|
|
|
- en: en
|
|
|
|
-}
|
|
|
|
-export const useLocaleStore = defineStore('locales', {
|
|
|
|
- state: () => {
|
|
|
|
- return {
|
|
|
|
- currentLocale: {
|
|
|
|
- lang: getLang() || 'zh-CN',
|
|
|
|
- elLocale: elLocaleMap[getLang() || 'zh-CN']
|
|
|
|
- },
|
|
|
|
- // 多语言
|
|
|
|
- localeMap: [
|
|
|
|
- {
|
|
|
|
- lang: 'zh-CN',
|
|
|
|
- name: '简体中文'
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- lang: 'zh-CN-Hant',
|
|
|
|
- name: '繁体中文'
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- lang: 'en',
|
|
|
|
- name: 'English'
|
|
|
|
- }
|
|
|
|
- ]
|
|
|
|
- }
|
|
|
|
- },
|
|
|
|
- getters: {
|
|
|
|
- getCurrentLocale() {
|
|
|
|
- return this.currentLocale
|
|
|
|
- },
|
|
|
|
- getLocaleMap() {
|
|
|
|
- return this.localeMap
|
|
|
|
- }
|
|
|
|
- },
|
|
|
|
- actions: {
|
|
|
|
- setCurrentLocale(localeMap) {
|
|
|
|
- // this.locale = Object.assign(this.locale, localeMap)
|
|
|
|
- this.currentLocale.lang = localeMap?.lang
|
|
|
|
- this.currentLocale.elLocale = elLocaleMap[localeMap?.lang]
|
|
|
|
- setLang(localeMap?.lang)
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-})
|
|
|
|
-
|
|
|
|
-export const useLocaleStoreWithOut = () => {
|
|
|
|
- return useLocaleStore(store)
|
|
|
|
-}
|
|
|