update
Some checks failed
Deploy / deploy (push) Has been cancelled

This commit is contained in:
2025-10-23 16:12:42 +08:00
parent 42ce9ac63b
commit 0a31cc3d2f
22 changed files with 318 additions and 257 deletions

View File

@@ -42,13 +42,7 @@ const columns: DataTableColumn<AdminProblemFiltered>[] = [
async function getList() {
const offset = (query.page - 1) * query.limit
const res = await getProblemList(
offset,
query.limit,
query.keyword,
"",
"",
)
const res = await getProblemList(offset, query.limit, query.keyword, "", "")
total.value = res.total
problems.value = res.results
}

View File

@@ -1,5 +1,15 @@
<script setup lang="ts">
import { NModal, NForm, NFormItem, NInput, NInputNumber, NSelect, NButton, NFlex, NImage } from "naive-ui"
import {
NModal,
NForm,
NFormItem,
NInput,
NInputNumber,
NSelect,
NButton,
NFlex,
NImage,
} from "naive-ui"
interface Props {
show: boolean
@@ -7,13 +17,16 @@ interface Props {
interface Emits {
(e: "update:show", value: boolean): void
(e: "confirm", data: {
name: string
description: string
icon: string
condition_type: "all_problems" | "problem_count" | "score"
condition_value?: number
}): void
(
e: "confirm",
data: {
name: string
description: string
icon: string
condition_type: "all_problems" | "problem_count" | "score"
condition_value?: number
},
): void
}
const props = defineProps<Props>()
@@ -22,7 +35,9 @@ const emit = defineEmits<Emits>()
const newBadgeName = ref("")
const newBadgeDescription = ref("")
const newBadgeIcon = ref("")
const newBadgeConditionType = ref<"all_problems" | "problem_count" | "score">("all_problems")
const newBadgeConditionType = ref<"all_problems" | "problem_count" | "score">(
"all_problems",
)
const newBadgeConditionValue = ref(1)
// 预设奖章图标选项
@@ -61,15 +76,18 @@ function handleCancel() {
}
// 重置表单
watch(() => props.show, (newVal) => {
if (newVal) {
newBadgeName.value = ""
newBadgeDescription.value = ""
newBadgeIcon.value = ""
newBadgeConditionType.value = "all_problems"
newBadgeConditionValue.value = 1
}
})
watch(
() => props.show,
(newVal) => {
if (newVal) {
newBadgeName.value = ""
newBadgeDescription.value = ""
newBadgeIcon.value = ""
newBadgeConditionType.value = "all_problems"
newBadgeConditionValue.value = 1
}
},
)
</script>
<template>

View File

@@ -1,5 +1,14 @@
<script setup lang="ts">
import { NModal, NForm, NFormItem, NInput, NInputNumber, NSwitch, NButton, NFlex } from "naive-ui"
import {
NModal,
NForm,
NFormItem,
NInput,
NInputNumber,
NSwitch,
NButton,
NFlex,
} from "naive-ui"
interface Props {
show: boolean
@@ -7,13 +16,16 @@ interface Props {
interface Emits {
(e: "update:show", value: boolean): void
(e: "confirm", data: {
problem_id: string
order: number
is_required: boolean
score: number
hint: string
}): void
(
e: "confirm",
data: {
problem_id: string
order: number
is_required: boolean
score: number
hint: string
},
): void
}
const props = defineProps<Props>()
@@ -40,15 +52,18 @@ function handleCancel() {
}
// 重置表单
watch(() => props.show, (newVal) => {
if (newVal) {
newProblemId.value = ""
newProblemOrder.value = 0
newProblemRequired.value = true
newProblemScore.value = 0
newProblemHint.value = ""
}
})
watch(
() => props.show,
(newVal) => {
if (newVal) {
newProblemId.value = ""
newProblemOrder.value = 0
newProblemRequired.value = true
newProblemScore.value = 0
newProblemHint.value = ""
}
},
)
</script>
<template>

View File

@@ -19,15 +19,9 @@ defineEmits<Emits>()
<template>
<div>
<n-flex
justify="space-between"
align="center"
style="margin-bottom: 16px"
>
<n-flex justify="space-between" align="center" style="margin-bottom: 16px">
<h3>奖章列表</h3>
<n-button type="primary" @click="$emit('add-badge')">
添加奖章
</n-button>
<n-button type="primary" @click="$emit('add-badge')"> 添加奖章 </n-button>
</n-flex>
<n-data-table
:columns="[

View File

@@ -1,5 +1,15 @@
<script setup lang="ts">
import { NModal, NForm, NFormItem, NInput, NInputNumber, NSelect, NButton, NFlex, NImage } from "naive-ui"
import {
NModal,
NForm,
NFormItem,
NInput,
NInputNumber,
NSelect,
NButton,
NFlex,
NImage,
} from "naive-ui"
import { ProblemSetBadge } from "utils/types"
interface Props {
@@ -9,13 +19,16 @@ interface Props {
interface Emits {
(e: "update:show", value: boolean): void
(e: "confirm", data: {
name: string
description: string
icon: string
condition_type: "all_problems" | "problem_count" | "score"
condition_value?: number
}): void
(
e: "confirm",
data: {
name: string
description: string
icon: string
condition_type: "all_problems" | "problem_count" | "score"
condition_value?: number
},
): void
}
const props = defineProps<Props>()
@@ -24,7 +37,9 @@ const emit = defineEmits<Emits>()
const editBadgeName = ref("")
const editBadgeDescription = ref("")
const editBadgeIcon = ref("")
const editBadgeConditionType = ref<"all_problems" | "problem_count" | "score">("all_problems")
const editBadgeConditionType = ref<"all_problems" | "problem_count" | "score">(
"all_problems",
)
const editBadgeConditionValue = ref(1)
// 预设奖章图标选项
@@ -63,15 +78,19 @@ function handleCancel() {
}
// 当奖章数据变化时,更新表单数据
watch(() => props.badge, (newBadge) => {
if (newBadge) {
editBadgeName.value = newBadge.name
editBadgeDescription.value = newBadge.description
editBadgeIcon.value = newBadge.icon
editBadgeConditionType.value = newBadge.condition_type
editBadgeConditionValue.value = newBadge.condition_value
}
}, { immediate: true })
watch(
() => props.badge,
(newBadge) => {
if (newBadge) {
editBadgeName.value = newBadge.name
editBadgeDescription.value = newBadge.description
editBadgeIcon.value = newBadge.icon
editBadgeConditionType.value = newBadge.condition_type
editBadgeConditionValue.value = newBadge.condition_value
}
},
{ immediate: true },
)
</script>
<template>

View File

@@ -1,5 +1,14 @@
<script setup lang="ts">
import { NModal, NForm, NFormItem, NInput, NInputNumber, NSwitch, NButton, NFlex } from "naive-ui"
import {
NModal,
NForm,
NFormItem,
NInput,
NInputNumber,
NSwitch,
NButton,
NFlex,
} from "naive-ui"
import { ProblemSetProblem } from "utils/types"
interface Props {
@@ -9,12 +18,15 @@ interface Props {
interface Emits {
(e: "update:show", value: boolean): void
(e: "confirm", data: {
order: number
is_required: boolean
score: number
hint: string
}): void
(
e: "confirm",
data: {
order: number
is_required: boolean
score: number
hint: string
},
): void
}
const props = defineProps<Props>()
@@ -30,7 +42,7 @@ function handleConfirm() {
order: editProblemOrder.value,
is_required: editProblemRequired.value,
score: editProblemScore.value,
hint: editProblemHint.value,
hint: editProblemHint.value || "",
})
}
@@ -39,14 +51,18 @@ function handleCancel() {
}
// 当问题数据变化时,更新表单数据
watch(() => props.problem, (newProblem) => {
if (newProblem) {
editProblemOrder.value = newProblem.order
editProblemRequired.value = newProblem.is_required
editProblemScore.value = newProblem.score
editProblemHint.value = newProblem.hint
}
}, { immediate: true })
watch(
() => props.problem,
(newProblem) => {
if (newProblem) {
editProblemOrder.value = newProblem.order
editProblemRequired.value = newProblem.is_required
editProblemScore.value = newProblem.score
editProblemHint.value = newProblem.hint || ""
}
},
{ immediate: true },
)
</script>
<template>

View File

@@ -19,11 +19,7 @@ defineEmits<Emits>()
<template>
<div>
<n-flex
justify="space-between"
align="center"
style="margin-bottom: 16px"
>
<n-flex justify="space-between" align="center" style="margin-bottom: 16px">
<h3>题目列表</h3>
<n-button type="primary" @click="$emit('add-problem')">
添加题目

View File

@@ -60,11 +60,7 @@ const progressColumns = [
<template>
<div>
<n-flex
justify="space-between"
align="center"
style="margin-bottom: 16px"
>
<n-flex justify="space-between" align="center" style="margin-bottom: 16px">
<h3>用户进度</h3>
</n-flex>
<n-data-table :columns="progressColumns" :data="progress" />

View File

@@ -242,18 +242,15 @@ onMounted(() => {
v-model:show="showAddProblemModal"
@confirm="handleAddProblem"
/>
<EditProblemModal
v-model:show="showEditProblemModal"
:problem="editingProblem"
@confirm="handleEditProblem"
/>
<AddBadgeModal
v-model:show="showAddBadgeModal"
@confirm="handleAddBadge"
/>
<AddBadgeModal v-model:show="showAddBadgeModal" @confirm="handleAddBadge" />
<EditBadgeModal
v-model:show="showEditBadgeModal"
:badge="editingBadge"

View File

@@ -148,7 +148,10 @@ watchDebounced(() => query.keyword, listProblemSets, {
})
// 监听其他查询条件变化
watch(() => [query.page, query.limit, query.difficulty, query.status], listProblemSets)
watch(
() => [query.page, query.limit, query.difficulty, query.status],
listProblemSets,
)
</script>
<template>