fix
Some checks failed
Deploy / deploy (build, debian, 22, /root/OJDeploy/data/clientnext) (push) Has been cancelled
Deploy / deploy (build:staging, school, 8822, /root/OJ/data/dist) (push) Has been cancelled

This commit is contained in:
2026-05-20 09:32:08 -06:00
parent 9093ba56e6
commit 2850887ce3
3 changed files with 23 additions and 4 deletions

View File

@@ -4,6 +4,7 @@ import { addProblemForContest } from "admin/api"
interface Props {
problemID: number
contestID: string
nextDisplayId?: string
}
const props = defineProps<Props>()
const emit = defineEmits(["added"])
@@ -39,7 +40,7 @@ async function addProblem() {
</template>
<n-flex vertical>
<span>请输入在这场比赛中的显示编号</span>
<n-input autofocus v-model:value="displayID" />
<n-input autofocus v-model:value="displayID" :placeholder="props.nextDisplayId ?? ''" />
</n-flex>
</n-popconfirm>
</template>

View File

@@ -1,12 +1,13 @@
<script lang="ts" setup>
import { getProblemList } from "admin/api"
import Pagination from "shared/components/Pagination.vue"
import { AdminProblemFiltered } from "utils/types"
import type { AdminProblemFiltered } from "utils/types"
import AddButton from "./AddButton.vue"
interface Props {
show: boolean
count: number
nextDisplayId?: string
}
const props = defineProps<Props>()
const emit = defineEmits<{
@@ -34,6 +35,7 @@ const columns: DataTableColumn<AdminProblemFiltered>[] = [
h(AddButton, {
problemID: row.id,
contestID: route.params.contestID as string,
nextDisplayId: props.nextDisplayId,
onAdded: () => emit("change"),
}),
width: 60,
@@ -53,7 +55,14 @@ watch(
},
)
watch(() => [query.limit, query.page], getList)
watchDebounced(() => query.keyword, getList, { debounce: 500, maxWait: 1000 })
watchDebounced(
() => query.keyword,
() => {
query.page = 1
getList()
},
{ debounce: 500, maxWait: 1000 },
)
</script>
<template>
<n-modal

View File

@@ -34,6 +34,15 @@ const { count, inc } = useCounter(0)
const total = ref(0)
const problems = ref<AdminProblemFiltered[]>([])
const nextDisplayID = computed(() => {
if (!isContestProblemList.value || problems.value.length === 0) return ""
const ids = problems.value.map((p) => p._id)
if (ids.every((id) => /^\d+$/.test(id))) {
return String(Math.max(...ids.map((id) => parseInt(id))) + 1)
}
return ""
})
interface ProblemQuery {
keyword: string
author: string
@@ -184,7 +193,7 @@ watch(() => [query.page, query.limit, query.author], listProblems)
v-model:limit="query.limit"
v-model:page="query.page"
/>
<Modal v-model:show="show" :count="count" @change="listProblems" />
<Modal v-model:show="show" :count="count" :next-display-id="nextDisplayID" @change="listProblems" />
</template>
<style scoped>