From 4e95a2fad0508c68e233662a6f3f6d977ee4d6d8 Mon Sep 17 00:00:00 2001 From: yuetsh <517252939@qq.com> Date: Wed, 18 Mar 2026 18:40:15 +0800 Subject: [PATCH] update --- src/api.ts | 16 -- src/components/Challenge.vue | 25 +- src/components/Task.vue | 10 +- .../submissions/ExpandedSubTable.vue | 20 ++ src/pages/Leaderboard.vue | 46 ---- src/pages/MyScores.vue | 64 ----- src/pages/Ranking.vue | 222 ------------------ src/pages/Submissions.vue | 38 ++- src/pages/TutorialEditor.vue | 3 - src/router.ts | 17 -- tsconfig.app.json | 2 +- 11 files changed, 41 insertions(+), 422 deletions(-) delete mode 100644 src/pages/Leaderboard.vue delete mode 100644 src/pages/MyScores.vue delete mode 100644 src/pages/Ranking.vue diff --git a/src/api.ts b/src/api.ts index a9207b0..b307536 100644 --- a/src/api.ts +++ b/src/api.ts @@ -68,11 +68,6 @@ export const Account = { return res.data }, - async leaderboard() { - const res = await http.get("/account/leaderboard") - return res.data as { rank: number; username: string; total_score: number }[] - }, - async listClasses(): Promise { const res = await http.get("/account/classes") return res.data @@ -226,17 +221,6 @@ export const Submission = { return res.data as { nominated: boolean } }, - async myScores() { - const res = await http.get("/submission/my-scores") - return res.data as { - task_id: number - task_display: number - task_title: string - score: number - created: string - }[] - }, - } export const Prompt = { diff --git a/src/components/Challenge.vue b/src/components/Challenge.vue index 908065b..bd3bc85 100644 --- a/src/components/Challenge.vue +++ b/src/components/Challenge.vue @@ -19,14 +19,6 @@ @@ -39,7 +31,7 @@ import { ref, onMounted } from "vue" import { Icon } from "@iconify/vue" import { marked } from "marked" import { useRouter } from "vue-router" -import { Challenge, Submission } from "../api" +import { Challenge } from "../api" import { taskTab, taskId, challengeDisplay } from "../store/task" import { TASK_TYPE } from "../utils/const" import type { ChallengeSlim } from "../utils/type" @@ -48,16 +40,6 @@ const router = useRouter() const challenges = ref([]) const currentChallenge = ref(null) const content = ref("") -const myScoreMap = ref>(new Map()) - -async function loadMyScores() { - try { - const scores = await Submission.myScores() - myScoreMap.value = new Map(scores.map((s) => [s.task_display, s.score])) - } catch { - // 未登录时忽略 - } -} async function loadList() { challenges.value = await Challenge.listDisplay() @@ -90,10 +72,7 @@ function back() { router.push({ name: "home-challenge-list" }) } -onMounted(async () => { - await loadList() - await loadMyScores() -}) +onMounted(loadList) diff --git a/src/pages/MyScores.vue b/src/pages/MyScores.vue deleted file mode 100644 index 4a97175..0000000 --- a/src/pages/MyScores.vue +++ /dev/null @@ -1,64 +0,0 @@ - - - - - diff --git a/src/pages/Ranking.vue b/src/pages/Ranking.vue deleted file mode 100644 index ca31e9f..0000000 --- a/src/pages/Ranking.vue +++ /dev/null @@ -1,222 +0,0 @@ - - - - - diff --git a/src/pages/Submissions.vue b/src/pages/Submissions.vue index 1696d04..903b529 100644 --- a/src/pages/Submissions.vue +++ b/src/pages/Submissions.vue @@ -178,6 +178,7 @@ const columns: DataTableColumn[] = [ onSelect: (id) => getSubmissionByID(id), onDelete: (r, parentId) => handleDelete(r, parentId), "onShow-chain": (id) => showChain(id), + onNominate: (r) => handleNominateChild(r, row.id), }), }, { @@ -191,25 +192,6 @@ const columns: DataTableColumn[] = [ "onUpdate:flag": (flag: FlagType) => updateFlag(row, flag), }), }, - { - title: "排名", - key: "nominated", - width: 60, - render: (row) => { - if (row.username !== user.username) { - return row.nominated ? h("span", { style: { color: "#f0a020" } }, "🏅") : null - } - return h( - NButton, - { - text: true, - title: row.nominated ? "已参与排名(点击可重新提名)" : "参与排名", - onClick: (e: Event) => { e.stopPropagation(); handleNominate(row) }, - }, - () => (row.nominated ? "🏅" : "☆"), - ) - }, - }, { title: "时间", key: "created", @@ -277,7 +259,17 @@ async function handleDelete(row: SubmissionOut, parentId: string) { } function rowProps(row: SubmissionOut) { - return { style: { cursor: "pointer" }, onClick: () => getSubmissionByID(row.id) } + return { + style: { cursor: "pointer" }, + onClick: () => { + getSubmissionByID(row.id) + handleExpand( + expandedKeys.value.includes(row.id) + ? expandedKeys.value.filter((k) => k !== row.id) + : [...expandedKeys.value, row.id], + ) + }, + } } function rowClassName(row: SubmissionOut) { @@ -296,8 +288,12 @@ async function getSubmissionByID(id: string) { submission.value = await Submission.get(id) } -async function handleNominate(row: SubmissionOut) { +async function handleNominateChild(row: SubmissionOut, parentId: string) { await Submission.nominate(row.id) + const items = expandedData.get(parentId) + if (items) { + expandedData.set(parentId, items.map((d) => ({ ...d, nominated: d.id === row.id }))) + } data.value = data.value.map((d) => { if (d.username === user.username && d.task_id === row.task_id) { d.nominated = d.id === row.id diff --git a/src/pages/TutorialEditor.vue b/src/pages/TutorialEditor.vue index 2f0cb55..b5c882a 100644 --- a/src/pages/TutorialEditor.vue +++ b/src/pages/TutorialEditor.vue @@ -81,7 +81,6 @@ const message = useMessage() const confirm = useDialog() const list = ref([]) -const content = ref("") const tutorial = reactive({ display: 0, title: "", @@ -102,7 +101,6 @@ function createNew() { tutorial.title = "" tutorial.content = "" tutorial.is_public = false - content.value = "" } async function submit() { @@ -114,7 +112,6 @@ async function submit() { tutorial.content = "" tutorial.is_public = false await getContent() - content.value = "" } catch (error: any) { message.error(error.response.data.detail) } diff --git a/src/router.ts b/src/router.ts index 48d33b6..e33d617 100644 --- a/src/router.ts +++ b/src/router.ts @@ -25,23 +25,6 @@ const routes = [ component: () => import("./pages/Submission.vue"), props: true, }, - { - path: "/leaderboard", - name: "leaderboard", - component: () => import("./pages/Leaderboard.vue"), - }, - { - path: "/ranking", - name: "ranking", - component: () => import("./pages/Ranking.vue"), - meta: { auth: true }, - }, - { - path: "/my-scores", - name: "my-scores", - component: () => import("./pages/MyScores.vue"), - meta: { auth: true }, - }, { path: "/dashboard", name: "dashboard", diff --git a/tsconfig.app.json b/tsconfig.app.json index 7fb078c..00b364a 100644 --- a/tsconfig.app.json +++ b/tsconfig.app.json @@ -10,5 +10,5 @@ "noFallthroughCasesInSwitch": true, "noUncheckedSideEffectImports": true }, - "include": ["src/**/*.ts", "src/**/*.tsx", "src/**/*.vue"] + "include": ["src/**/*.ts", "src/**/*.vue"] }