feat(字典管理): 新增字典管理功能及相关基础设施
- 新增字典管理页面,支持字典项的增删改查 - 添加 pinia-plugin-persistedstate 依赖,实现状态持久化 - 创建字典相关的 API 类型定义和服务接口 - 实现字典数据存储模块,支持字典数据的缓存和复用 - 添加 useDict 组合式函数,方便组件中使用字典数据 - 在题目分类和比赛创建模块中使用字典数据替代硬编码选项 - 优化分类树组件,添加拖拽手柄和题目类型选择
This commit is contained in:
29
apps/admin/src/hooks/business/useDict.ts
Normal file
29
apps/admin/src/hooks/business/useDict.ts
Normal file
@ -0,0 +1,29 @@
|
||||
import { computed, onMounted } from 'vue'
|
||||
import { useBusinessStore } from '@/store/modules/business'
|
||||
|
||||
export function useDict(key: string) {
|
||||
const store = useBusinessStore()
|
||||
|
||||
const data = computed(() => store.dictData[key] || [])
|
||||
const loading = computed(() => store.loadingMap[key] || false)
|
||||
|
||||
const options = computed(() => {
|
||||
if (data.value && data.value.length > 0) {
|
||||
return data.value.map((item: any) => ({
|
||||
label: item.uI_Key || item.UI_Key || item.DicKey,
|
||||
value: item.uI_Value || item.UI_Value || item.DicValue,
|
||||
}))
|
||||
}
|
||||
return []
|
||||
})
|
||||
|
||||
onMounted(() => {
|
||||
store.getDict(key)
|
||||
})
|
||||
|
||||
return {
|
||||
data,
|
||||
options,
|
||||
loading,
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user