import { defineStore } from 'pinia'
import { store } from '/@/store'

interface dictItem {
    color: string
    jsonObject?: string
    label: string
    text: string
    title: string
    value: string | number
}
// 定义字典列表的类型
export interface DictListVO {
    [key: string]: dictItem[]
}
export const useDictStore = defineStore({
    id: 'dict',
    state: () => ({
        dictList: {} as DictListVO,
    }),
    getters: {
        getDictList(): DictListVO {
            return this.dictList
        },
    },
    actions: {
        setDictList(dictList: DictListVO): void {
            this.dictList = dictList
        },
        /**
         * 清空字典数据
         */
        clearDict(): void {
            this.dictList = {}
        },
    },
})

// Need to be used outside the setup
export function useAppStoreWithOut() {
    return useDictStore(store)
}
