add title.

This commit is contained in:
2023-03-30 19:24:15 +08:00
parent eb652d1c86
commit 451e8d7c70
8 changed files with 78 additions and 34 deletions

View File

@@ -70,7 +70,7 @@ async function submit() {
try { try {
await api!(contest) await api!(contest)
if (route.name === "admin contest create") { if (route.name === "admin contest create") {
message.success("成功建比赛 💐") message.success("成功建比赛 💐")
} else { } else {
message.success("修改已保存") message.success("修改已保存")
} }
@@ -84,9 +84,12 @@ onMounted(getContestDetail)
</script> </script>
<template> <template>
<h2 class="title">
{{ $route.name === "admin contest create" ? "新建比赛" : "编辑比赛" }}
</h2>
<n-form inline> <n-form inline>
<n-form-item label="标题"> <n-form-item label="标题">
<n-input class="title" v-model:value="contest.title" /> <n-input class="contestTitle" v-model:value="contest.title" />
</n-form-item> </n-form-item>
<n-form-item label="开始"> <n-form-item label="开始">
<n-date-picker v-model:value="startTime" type="datetime" /> <n-date-picker v-model:value="startTime" type="datetime" />
@@ -112,6 +115,10 @@ onMounted(getContestDetail)
<style scoped> <style scoped>
.title { .title {
margin-top: 0;
}
.contestTitle {
width: 400px; width: 400px;
} }
</style> </style>

View File

@@ -74,11 +74,10 @@ watch(query, listContests, { deep: true })
</script> </script>
<template> <template>
<n-form inline label-placement="left"> <n-space justify="space-between" class="titleWrapper">
<n-form-item> <h2 class="title">比赛列表</h2>
<n-input v-model:value="query.keyword" placeholder="输入标题关键字" /> <n-input v-model:value="query.keyword" placeholder="输入标题关键字" />
</n-form-item> </n-space>
</n-form>
<n-data-table :columns="columns" :data="contests" size="small" /> <n-data-table :columns="columns" :data="contests" size="small" />
<Pagination <Pagination
:total="total" :total="total"
@@ -87,4 +86,12 @@ watch(query, listContests, { deep: true })
/> />
</template> </template>
<style scoped></style> <style scoped>
.titleWrapper {
margin-bottom: 16px;
}
.title {
margin: 0;
}
</style>

View File

@@ -27,6 +27,15 @@ const route = useRoute()
const router = useRouter() const router = useRouter()
const props = defineProps<Props>() const props = defineProps<Props>()
const title = computed(
() =>
({
"admin problem create": "新建题目",
"admin problem edit": "编辑题目",
"admin contest problem create": "新建比赛题目",
"admin contest problem edit": "编辑比赛题目",
}[<string>route.name])
)
const problem = reactive<BlankProblem>({ const problem = reactive<BlankProblem>({
_id: "", _id: "",
title: "", title: "",
@@ -321,12 +330,13 @@ watch([fromExistingTags, newTags], (tags) => {
</script> </script>
<template> <template>
<h2 class="title">{{ title }}</h2>
<n-form inline label-placement="left"> <n-form inline label-placement="left">
<n-form-item label="显示编号"> <n-form-item label="显示编号">
<n-input class="w-100" v-model:value="problem._id" /> <n-input class="w-100" v-model:value="problem._id" />
</n-form-item> </n-form-item>
<n-form-item label="题目"> <n-form-item label="题目">
<n-input class="titleInput" v-model:value="problem.title" /> <n-input class="problemTitleInput" v-model:value="problem.title" />
</n-form-item> </n-form-item>
<n-form-item label="难度"> <n-form-item label="难度">
<n-select <n-select
@@ -497,6 +507,10 @@ watch([fromExistingTags, newTags], (tags) => {
</template> </template>
<style scoped> <style scoped>
.title {
margin-top: 0;
}
.box { .box {
margin-bottom: 20px; margin-bottom: 20px;
} }
@@ -505,13 +519,10 @@ watch([fromExistingTags, newTags], (tags) => {
width: 100px; width: 100px;
} }
.titleInput { .problemTitleInput {
width: 300px; width: 300px;
} }
.title {
margin-bottom: 12px;
}
.tag { .tag {
width: 500px; width: 500px;
} }

View File

@@ -83,11 +83,10 @@ watch(query, listProblems, { deep: true })
</script> </script>
<template> <template>
<n-form inline label-placement="left"> <n-space class="titleWrapper" justify="space-between">
<n-form-item> <h2 class="title">题目列表</h2>
<n-input v-model:value="query.keyword" placeholder="输入标题关键字" /> <n-input v-model:value="query.keyword" placeholder="输入标题关键字" />
</n-form-item> </n-space>
</n-form>
<n-data-table striped size="small" :columns="columns" :data="problems" /> <n-data-table striped size="small" :columns="columns" :data="problems" />
<Pagination <Pagination
:total="total" :total="total"
@@ -96,4 +95,12 @@ watch(query, listProblems, { deep: true })
/> />
</template> </template>
<style scoped></style> <style scoped>
.titleWrapper {
margin-bottom: 16px;
}
.title {
margin: 0;
}
</style>

View File

@@ -28,6 +28,10 @@ const usersToTable = computed(() => {
}) })
function generateUsers() { function generateUsers() {
if (!rawInput.value || !rawInput.value.trim()) {
message.info("请填写相关内容")
return
}
// 自动加上 ks 的开头 // 自动加上 ks 的开头
let myClass = "" let myClass = ""
if (prefix.value) { if (prefix.value) {
@@ -37,7 +41,6 @@ function generateUsers() {
myClass = prefix.value myClass = prefix.value
} }
} }
if (!rawInput.value || !rawInput.value.trim()) return
rawInput.value = rawInput.value.trim() rawInput.value = rawInput.value.trim()
const inputs = rawInput.value.split("\n") const inputs = rawInput.value.split("\n")
users.value = inputs.map((u, i) => { users.value = inputs.map((u, i) => {
@@ -88,7 +91,6 @@ function handleAll() {
type="textarea" type="textarea"
class="inputArea" class="inputArea"
placeholder="每行一个用户名" placeholder="每行一个用户名"
autofocus
v-model:value="rawInput" v-model:value="rawInput"
/> />
</n-space> </n-space>

View File

@@ -120,19 +120,21 @@ watch(query, listUsers, { deep: true })
</script> </script>
<template> <template>
<n-form inline label-placement="left"> <n-space class="titleWrapper" justify="space-between">
<n-form-item> <h2 class="title">用户列表</h2>
<n-input placeholder="请输入关键字搜索" v-model:value="query.keyword" /> <n-space>
</n-form-item> <n-popconfirm
<n-form-item v-if="userIDs.length"> v-if="userIDs.length"
<n-popconfirm @positive-click="onDeleteUsers(userIDs)"> @positive-click="onDeleteUsers(userIDs)"
>
<template #trigger> <template #trigger>
<n-button type="warning">删除</n-button> <n-button type="warning">删除</n-button>
</template> </template>
确定删除选中的用户吗删除后无法恢复 确定删除选中的用户吗删除后无法恢复
</n-popconfirm> </n-popconfirm>
</n-form-item> <n-input placeholder="请输入关键字搜索" v-model:value="query.keyword" />
</n-form> </n-space>
</n-space>
<n-data-table <n-data-table
:data="users" :data="users"
:columns="columns" :columns="columns"
@@ -183,4 +185,12 @@ watch(query, listUsers, { deep: true })
</n-modal> </n-modal>
</template> </template>
<style scoped></style> <style scoped>
.titleWrapper {
margin-bottom: 16px;
}
.title {
margin: 0;
}
</style>

View File

@@ -44,13 +44,13 @@ onMounted(init)
:column="2" :column="2"
label-style="width: 50%" label-style="width: 50%"
> >
<n-descriptions-item label="已解决的题数量"> <n-descriptions-item label="已解决的题数量">
{{ profile.accepted_number }} {{ profile.accepted_number }}
</n-descriptions-item> </n-descriptions-item>
<n-descriptions-item label="总提交数"> <n-descriptions-item label="总提交数">
{{ profile.submission_number }} {{ profile.submission_number }}
</n-descriptions-item> </n-descriptions-item>
<n-descriptions-item v-if="problems.length" label="已解决的题" :span="2"> <n-descriptions-item v-if="problems.length" label="已解决的题" :span="2">
<n-space> <n-space>
<n-button <n-button
v-for="id in problems" v-for="id in problems"

View File

@@ -36,7 +36,7 @@ const options: MenuOption[] = [
h( h(
RouterLink, RouterLink,
{ to: "/admin/problem/create" }, { to: "/admin/problem/create" },
{ default: () => "建题目" } { default: () => "建题目" }
), ),
key: "admin problem create", key: "admin problem create",
}, },
@@ -70,7 +70,7 @@ const options: MenuOption[] = [
h( h(
RouterLink, RouterLink,
{ to: "/admin/contest/create" }, { to: "/admin/contest/create" },
{ default: () => "建比赛" } { default: () => "建比赛" }
), ),
key: "admin contest create", key: "admin contest create",
}, },