feat(字典管理): 新增字典管理功能及相关基础设施

- 新增字典管理页面,支持字典项的增删改查
- 添加 pinia-plugin-persistedstate 依赖,实现状态持久化
- 创建字典相关的 API 类型定义和服务接口
- 实现字典数据存储模块,支持字典数据的缓存和复用
- 添加 useDict 组合式函数,方便组件中使用字典数据
- 在题目分类和比赛创建模块中使用字典数据替代硬编码选项
- 优化分类树组件,添加拖拽手柄和题目类型选择
This commit is contained in:
2026-01-30 17:45:46 +08:00
parent b39761d58e
commit e1a19c48e0
21 changed files with 678 additions and 16 deletions

View File

@ -1,7 +1,7 @@
<script setup lang="ts">
import { NButton, NModal, NStep, NSteps } from 'naive-ui'
import { computed, onMounted, ref, useTemplateRef, watch } from 'vue'
import { roundTypeOptions, scoreTypeOptions } from '@/constants/business'
import { useDict } from '@/hooks/business/useDict'
import { fetchCreateActivity, fetchCreateQuestion, fetchCreateTeamList, fetchGetRoomList } from '@/service/api/competition'
/** 房间相关接口 */
import BasicInfo from './modules/BasicInfo.vue'
@ -19,6 +19,9 @@ const emit = defineEmits<{
(e: 'success'): void
}>()
const { options: roundTypeOptions } = useDict('round_type')
const { options: scoreTypeOptions } = useDict('score_type')
const currentStep = ref<number>(1)
/** 房间列表 */
const roomListOptions = ref<{ label: string, value: number }[]>([])
@ -42,13 +45,13 @@ const competitionData = ref({
{
id: 'round_default',
name: '星·辞海遨游',
roundType: roundTypeOptions[0].value,
roundType: roundTypeOptions.value?.[0]?.value,
questions: Array.from({ length: 10 }).map(() => ({
value: null,
score: 5,
time: 30,
title: '第1题',
scoreType: scoreTypeOptions[0].value,
scoreType: scoreTypeOptions.value?.[0]?.value,
})),
},
],

View File

@ -2,7 +2,7 @@
import { NButton, NForm, NFormItem, NInput, NInputNumber, NModal, NSelect, type SelectOption } from 'naive-ui'
import { onMounted, ref, watch } from 'vue'
import { VueDraggable } from 'vue-draggable-plus'
import { roundTypeOptions, scoreTypeOptions, timeOptions, uiTypeOptions } from '@/constants/business'
import { useDict } from '@/hooks/business/useDict'
import { fetchGetQuestionListAll } from '@/service/api/question'
import { fetchTemplateList } from '@/service/api/template'
import { useQuestionConfig } from './useQuestionConfig'
@ -26,6 +26,12 @@ const props = defineProps<{
}>
}
}>()
const { options: roundTypeOptions } = useDict('round_type')
const { options: scoreTypeOptions } = useDict('score_type')
const { options: timeOptions } = useDict('time_out')
const { options: uiTypeOptions } = useDict('ui_type')
const {
// getRoundScore,
getRoundTime,
@ -47,14 +53,14 @@ const showAddModal = ref(false)
const newRoundForm = ref({
name: '',
count: 10,
roundType: roundTypeOptions[0].value,
roundType: roundTypeOptions?.value?.[0].value || '',
})
function handleOpenAddModal() {
newRoundForm.value = {
name: `${(props.modelValue?.rounds?.length || 0) + 1}轮 星·诗词大会`,
count: 10,
roundType: roundTypeOptions[0].value,
roundType: roundTypeOptions?.value?.[0].value || '',
}
showAddModal.value = true
}