mirror of
https://github.com/m-xlsea/ruoyi-plus-soybean.git
synced 2025-09-24 07:49:47 +08:00
feat: 封装数据字典
This commit is contained in:
35
src/store/modules/dict/index.ts
Normal file
35
src/store/modules/dict/index.ts
Normal file
@ -0,0 +1,35 @@
|
||||
import { defineStore } from 'pinia';
|
||||
import { ref } from 'vue';
|
||||
|
||||
export const useDictStore = defineStore('dict', () => {
|
||||
const dictData = ref<{ [key: string]: Array<Api.System.DictData> }>({});
|
||||
|
||||
const getDict = (key: string) => {
|
||||
return dictData.value[key];
|
||||
};
|
||||
|
||||
const setDict = (key: string, dict: Array<Api.System.DictData>) => {
|
||||
dictData.value[key] = dict;
|
||||
};
|
||||
|
||||
const removeDict = (key: string) => {
|
||||
if (key in dictData.value) {
|
||||
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete
|
||||
delete dictData.value[key];
|
||||
}
|
||||
};
|
||||
|
||||
const cleanDict = () => {
|
||||
dictData.value = {};
|
||||
};
|
||||
|
||||
return {
|
||||
dictData,
|
||||
getDict,
|
||||
setDict,
|
||||
removeDict,
|
||||
cleanDict
|
||||
};
|
||||
});
|
||||
|
||||
export default useDictStore;
|
Reference in New Issue
Block a user