add contest problems.

This commit is contained in:
2023-03-30 23:18:31 +08:00
parent 451e8d7c70
commit 70a4b67b58
10 changed files with 378 additions and 176 deletions

View File

@@ -0,0 +1,44 @@
<script setup lang="ts">
import { addProblemForContest } from "~/admin/api"
interface Props {
problemID: number
contestID: string
}
const props = defineProps<Props>()
const emit = defineEmits(["added"])
const message = useMessage()
const displayID = ref("")
async function addProblem() {
if (!displayID.value) return
try {
await addProblemForContest(
props.contestID,
props.problemID,
displayID.value
)
emit("added")
} catch (err: any) {
if (err.data === "Duplicate display id in this contest") {
message.error("显示编号重复了,请重新写一个")
} else {
message.error(err.data)
}
}
}
</script>
<template>
<n-popconfirm :show-icon="false" @positive-click="addProblem">
<template #trigger>
<n-button secondary size="small" type="primary">+</n-button>
</template>
<n-space vertical>
<span>请输入在这场比赛中的显示编号</span>
<n-input autofocus v-model:value="displayID" />
</n-space>
</n-popconfirm>
</template>
<style scoped></style>