github.com/e154/smart-home@v0.17.2-0.20240311175135-e530a6e5cd45/static_source/admin/src/store/modules/dict.ts (about)

     1  import { defineStore } from 'pinia'
     2  import { store } from '../index'
     3  
     4  export interface DictState {
     5    isSetDict: boolean
     6    dictObj: Recordable
     7  }
     8  
     9  export const useDictStore = defineStore('dict', {
    10    state: (): DictState => ({
    11      isSetDict: false,
    12      dictObj: {}
    13    }),
    14    getters: {
    15      getDictObj(): Recordable {
    16        return this.dictObj
    17      },
    18      getIsSetDict(): boolean {
    19        return this.isSetDict
    20      }
    21    },
    22    actions: {
    23      setDictObj(dictObj: Recordable) {
    24        this.dictObj = dictObj
    25      },
    26      setIsSetDict(isSetDict: boolean) {
    27        this.isSetDict = isSetDict
    28      }
    29    }
    30  })
    31  
    32  export const useDictStoreWithOut = () => {
    33    return useDictStore(store)
    34  }