优化全局注入dict_data
This commit is contained in:
18
web/apps/web-antd/src/store/dict.ts
Normal file
18
web/apps/web-antd/src/store/dict.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
// src/store/dict.ts
|
||||
import { defineStore } from 'pinia';
|
||||
|
||||
import { getDictDataSimple } from '#/api/system/dict_data'; // 根据实际路径调整
|
||||
|
||||
export const useDictStore = defineStore('dict', {
|
||||
state: () => ({
|
||||
dictData: [] as any[],
|
||||
}),
|
||||
actions: {
|
||||
async fetchDictData() {
|
||||
this.dictData = await getDictDataSimple(); // 根据接口返回结构调整
|
||||
},
|
||||
getOptionsByType(type: string) {
|
||||
return this.dictData.filter((item) => item.dict_type === type);
|
||||
},
|
||||
},
|
||||
});
|
||||
Reference in New Issue
Block a user