12345678910111213141516171819202122232425262728293031323334353637383940 |
- /**
- * 用户存储全局一些 状态 和 类型的数据词典
- */
- import {defineStore} from "pinia";
- import {DictApi} from "/@/api/admin/Dict";
- const arr =
- ['componentStatus',
- 'componentType',
- 'componentStatusType',
- 'componentTypeListStatus',
- 'productionLogListStatus',
- 'groupLogoKeyKeyType',
- 'groupKeyGroupStatus']
- export const useGlobalCacheStore = defineStore('globalCacheStore', {
- state: () => ({
- globalStore:new Map
- }),
- actions: {
- /**获取所有字典缓存*/
- async requestGlobalStore () {
- const { data } = await new DictApi().getList(arr)
- Object.keys(data as object).forEach(key => {
- const newMap = data?.[key]?.reduce((map, obj) => {
- // @ts-ignore
- obj.color = obj.code.split("_")[1] ?? ''
- map.set(obj.value,{...obj})
- return map
- },new Map)
- this.globalStore.set(key,newMap)
- })
- },
- getGlobalStore(){
- return this.globalStore
- },
- }
- })
|