From 73eb288d3cc9c864b8871ac4856b76bfaa9042ec Mon Sep 17 00:00:00 2001
From: yuetsh <517252939@qq.com>
Date: Tue, 2 Jul 2024 22:18:16 +0800
Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=90=8E=E7=AB=AF=E8=AF=84?=
=?UTF-8?q?=E8=AE=BA=E7=9A=84=E7=AE=A1=E7=90=86=E9=A1=B5=E9=9D=A2?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/admin/announcement/list.vue | 2 +-
src/admin/api.ts | 14 +++
src/admin/communication/comments.vue | 89 +++++++++++++++++++
.../components/CommentActions.vue | 23 +++++
src/admin/communication/messages.vue | 2 +
src/admin/contest/list.vue | 5 +-
src/admin/problem/components/Modal.vue | 2 +-
src/admin/problem/list.vue | 21 +++--
src/admin/setting/config.vue | 2 -
src/admin/user/list.vue | 1 -
src/oj/api.ts | 1 -
src/oj/problem/components/ProblemComment.vue | 9 +-
src/oj/problem/components/Submit.vue | 4 +-
src/oj/problem/detail.vue | 4 +-
.../submission/components/StatisticsPanel.vue | 1 -
src/routes.ts | 10 +++
src/shared/layout/admin.vue | 19 ++++
src/utils/types.ts | 11 +++
18 files changed, 198 insertions(+), 22 deletions(-)
create mode 100644 src/admin/communication/comments.vue
create mode 100644 src/admin/communication/components/CommentActions.vue
create mode 100644 src/admin/communication/messages.vue
diff --git a/src/admin/announcement/list.vue b/src/admin/announcement/list.vue
index ac064c3..d3574cd 100644
--- a/src/admin/announcement/list.vue
+++ b/src/admin/announcement/list.vue
@@ -81,7 +81,7 @@ watch(query, listAnnouncements, { deep: true })
网站公告
-
+
+
+ 评论列表
+
+
+
+
+
+
+
diff --git a/src/admin/communication/components/CommentActions.vue b/src/admin/communication/components/CommentActions.vue
new file mode 100644
index 0000000..0e42884
--- /dev/null
+++ b/src/admin/communication/components/CommentActions.vue
@@ -0,0 +1,23 @@
+
+
+
+
+ 删除
+
+ 确定删除这条评论吗?
+
+
diff --git a/src/admin/communication/messages.vue b/src/admin/communication/messages.vue
new file mode 100644
index 0000000..28e17fd
--- /dev/null
+++ b/src/admin/communication/messages.vue
@@ -0,0 +1,2 @@
+未完待续
+
diff --git a/src/admin/contest/list.vue b/src/admin/contest/list.vue
index 8a27162..8277c9c 100644
--- a/src/admin/contest/list.vue
+++ b/src/admin/contest/list.vue
@@ -78,7 +78,8 @@ async function listContests() {
total.value = res.data.total
}
onMounted(listContests)
-watch(query, listContests, { deep: true })
+watch(() => [query.page, query.limit], listContests)
+watchDebounced(() => query.keyword, listContests, { debounce: 500, maxWait: 1000 })
@@ -86,7 +87,7 @@ watch(query, listContests, { deep: true })
比赛列表
-
+
-
+
-import { getProblemList, getProblem, editProblem } from "../api"
+import {
+ getProblemList,
+ getProblem,
+ editProblem,
+ toggleProblemVisible,
+} from "../api"
import Pagination from "~/shared/components/Pagination.vue"
import { NSwitch } from "naive-ui"
import { AdminProblemFiltered } from "~/utils/types"
@@ -61,7 +66,7 @@ const columns: DataTableColumn[] = [
{
title: "选项",
key: "actions",
- width: 250,
+ width: 260,
render: (row) =>
h(Actions, {
problemID: row.id,
@@ -83,10 +88,8 @@ async function listProblems() {
problems.value = res.results
}
-// 这里比较傻逼,因为我传进来的时候 filter 了而且只有 edit problem 一个接口,所以只能先 get 再 edit
async function toggleVisible(problemID: number) {
- const res = await getProblem(problemID)
- await editProblem({ ...res.data, visible: !res.data.visible })
+ await toggleProblemVisible(problemID)
problems.value = problems.value.map((it) => {
if (it.id === problemID) {
it.visible = !it.visible
@@ -108,7 +111,11 @@ async function selectProblems() {
}
onMounted(listProblems)
-watch(query, listProblems, { deep: true })
+watch(() => [query.limit, query.page], listProblems)
+watchDebounced(() => query.keyword, listProblems, {
+ debounce: 500,
+ maxWait: 1000,
+})
@@ -128,7 +135,7 @@ watch(query, listProblems, { deep: true })
-
+
{
@@ -230,7 +229,6 @@ onMounted(() => {
@@ -36,7 +37,8 @@
v-if="hasCommented"
icon="noto:star"
:width="24"
- v-for="i in difficulty_rating"
+ v-for="(_, i) in difficulty_rating"
+ :key="i"
/>
@@ -50,7 +52,8 @@
v-if="hasCommented"
icon="noto:star"
:width="24"
- v-for="i in difficulty_rating"
+ v-for="(_, i) in difficulty_rating"
+ :key="i"
/>
diff --git a/src/oj/problem/components/Submit.vue b/src/oj/problem/components/Submit.vue
index bf4e7c6..92b34b0 100644
--- a/src/oj/problem/components/Submit.vue
+++ b/src/oj/problem/components/Submit.vue
@@ -212,7 +212,9 @@ watch(
origin: { x: 0.5, y: 0.4 },
})
// 题目在第一次完成之后,弹出点评框
- showCommentPanel()
+ if (!contestID) {
+ showCommentPanel()
+ }
}
},
)
diff --git a/src/oj/problem/detail.vue b/src/oj/problem/detail.vue
index 2ca6fb0..97447d2 100644
--- a/src/oj/problem/detail.vue
+++ b/src/oj/problem/detail.vue
@@ -72,7 +72,7 @@ onBeforeUnmount(() => {
-
+
@@ -90,7 +90,7 @@ onBeforeUnmount(() => {
-
+
diff --git a/src/oj/submission/components/StatisticsPanel.vue b/src/oj/submission/components/StatisticsPanel.vue
index d3db0d0..d21cc86 100644
--- a/src/oj/submission/components/StatisticsPanel.vue
+++ b/src/oj/submission/components/StatisticsPanel.vue
@@ -68,7 +68,6 @@
diff --git a/src/routes.ts b/src/routes.ts
index 63e046f..d01d670 100644
--- a/src/routes.ts
+++ b/src/routes.ts
@@ -182,5 +182,15 @@ export const admins: RouteRecordRaw = {
component: () => import("admin/announcement/detail.vue"),
props: true,
},
+ {
+ path: "comment/list",
+ name: "admin comment list",
+ component: () => import("admin/communication/comments.vue"),
+ },
+ {
+ path: "message/list",
+ name: "admin message list",
+ component: () => import("admin/communication/messages.vue"),
+ },
],
}
diff --git a/src/shared/layout/admin.vue b/src/shared/layout/admin.vue
index 5eb293d..22051ff 100644
--- a/src/shared/layout/admin.vue
+++ b/src/shared/layout/admin.vue
@@ -35,6 +35,25 @@ const options: MenuOption[] = [
),
key: "admin problem create",
},
+ {label: "交流", key: "communication", disabled: true},
+ {
+ label: () =>
+ h(
+ RouterLink,
+ { to: "/admin/comment/list" },
+ { default: () => "评论列表" },
+ ),
+ key: "admin comment list",
+ },
+ {
+ label: () =>
+ h(
+ RouterLink,
+ { to: "/admin/message/list" },
+ { default: () => "消息列表" },
+ ),
+ key: "admin message list",
+ },
{ label: "用户", key: "user", disabled: true },
{
label: () =>
diff --git a/src/utils/types.ts b/src/utils/types.ts
index 7973467..bda6eef 100644
--- a/src/utils/types.ts
+++ b/src/utils/types.ts
@@ -360,3 +360,14 @@ export interface CreateMessage {
submission: string
message: string
}
+
+export interface Comment {
+ id: number
+ problem: string
+ submission: string
+ content: string
+ description_rating: 1 | 2 | 3 | 4 | 5
+ difficulty_rating: 1 | 2 | 3 | 4 | 5
+ comprehensive_rating: 1 | 2 | 3 | 4 | 5
+ create_time: Date
+}