From d3348f994d6800c6d00229d9e777bb7e7aac7d2e Mon Sep 17 00:00:00 2001 From: yuetsh <517252939@qq.com> Date: Tue, 25 Aug 2026 14:03:51 -0600 Subject: [PATCH] =?UTF-8?q?fix(=E5=89=8D=E7=AB=AF):=20=E4=B8=80=E6=89=B9?= =?UTF-8?q?=E8=A1=A8=E6=A0=BC=E5=88=97=E9=9D=99=E9=BB=98=E7=A9=BA=E7=99=BD?= =?UTF-8?q?=EF=BC=8C=E9=A2=98=E5=8D=95=E8=BF=9B=E5=BA=A6=E7=82=B9=E3=80=8C?= =?UTF-8?q?=E7=A7=BB=E9=99=A4=E3=80=8D=E8=BF=98=E4=BC=9A=E6=8A=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 没有 render 的列,naive-ui 直接按 key 取 row[key]。上一批把响应字段改成 camelCase 之后,这些列的 key 还留着 snake_case,取不到值就渲染成空白 —— 排行榜、题单进度、AI 报告、后台首页共 13 处。 这类问题类型检查够不着(列 key 是字符串),是扫「没有 render 的列 key 里 还带下划线」的组合才找出来的。 同一张表还有两处更严重的: - 「用户」列 key 写的是 user.username,但后台 /admin/problem-sets/:id/progress 下发的是扁平的 username,没有嵌套 user。 - 点「移除」emit 的是 row.user.id —— row.user 是 undefined,直接抛, 学生根本移不掉。 test_case 那两处保留:读的是判题机 info.data 的原始键。 Co-Authored-By: Claude Opus 5 --- .../components/ProgressManagement.vue | 26 +++++++++---------- apps/web/src/admin/setting/home.vue | 4 +-- apps/web/src/oj/ai/components/SolvedTable.vue | 4 +-- .../components/UserProgressView.vue | 4 +-- apps/web/src/oj/rank/list.vue | 12 ++++----- 5 files changed, 25 insertions(+), 25 deletions(-) diff --git a/apps/web/src/admin/problemset/components/ProgressManagement.vue b/apps/web/src/admin/problemset/components/ProgressManagement.vue index 30d5a06..37ef946 100644 --- a/apps/web/src/admin/problemset/components/ProgressManagement.vue +++ b/apps/web/src/admin/problemset/components/ProgressManagement.vue @@ -2,10 +2,10 @@ import { h } from "vue" import { NDataTable, NButton, NFlex } from "naive-ui" import { parseTime } from "utils/functions" -import type { ProblemSetProgress } from "utils/types" +import type { AdminProblemSetProgress } from "utils/types" interface Props { - progress: ProblemSetProgress[] + progress: AdminProblemSetProgress[] } interface Emits { @@ -17,41 +17,41 @@ const emit = defineEmits() // 定义表格列 const progressColumns = [ - { title: "用户", key: "user.username", width: 120 }, + { title: "用户", key: "username", width: 120 }, { title: "加入时间", - key: "join_time", + key: "joinTime", width: 180, - render: (row: ProblemSetProgress) => + render: (row: AdminProblemSetProgress) => parseTime(row.joinTime, "YYYY-MM-DD HH:mm:ss"), }, - { title: "已完成", key: "completed_problems_count", width: 100 }, - { title: "总题目", key: "total_problems_count", width: 100 }, + { title: "已完成", key: "completedProblemsCount", width: 100 }, + { title: "总题目", key: "totalProblemsCount", width: 100 }, { title: "进度", - key: "progress_percentage", + key: "progressPercentage", width: 100, - render: (row: ProblemSetProgress) => + render: (row: AdminProblemSetProgress) => `${row.progressPercentage.toFixed(0)}%`, }, { title: "是否完成", - key: "is_completed", + key: "isCompleted", width: 100, - render: (row: ProblemSetProgress) => (row.isCompleted ? "是" : "否"), + render: (row: AdminProblemSetProgress) => (row.isCompleted ? "是" : "否"), }, { title: "操作", key: "actions", width: 120, - render: (row: ProblemSetProgress) => + render: (row: AdminProblemSetProgress) => h( NButton, { size: "small", type: "error", secondary: true, - onClick: () => emit("remove-user", row.user.id), + onClick: () => emit("remove-user", row.userId), }, { default: () => "移除" }, ), diff --git a/apps/web/src/admin/setting/home.vue b/apps/web/src/admin/setting/home.vue index 4e950ff..4ba8a7a 100644 --- a/apps/web/src/admin/setting/home.vue +++ b/apps/web/src/admin/setting/home.vue @@ -53,8 +53,8 @@ const columns: DataTableColumn[] = [ ), }, { title: "个性签名", key: "mood" }, - { title: "已解决", key: "accepted_number", width: 100 }, - { title: "提交数", key: "submission_number", width: 100 }, + { title: "已解决", key: "acceptedNumber", width: 100 }, + { title: "提交数", key: "submissionNumber", width: 100 }, { title: "正确率", key: "rate", diff --git a/apps/web/src/oj/ai/components/SolvedTable.vue b/apps/web/src/oj/ai/components/SolvedTable.vue index 56c7bea..8842be6 100644 --- a/apps/web/src/oj/ai/components/SolvedTable.vue +++ b/apps/web/src/oj/ai/components/SolvedTable.vue @@ -134,7 +134,7 @@ const flowchartsColumns: DataTableColumn[] = [ () => `${row.problemId} ${row.problemTitle}`, ), }, - { title: "提交次数", key: "submission_count", width: 100, align: "center" }, + { title: "提交次数", key: "submissionCount", width: 100, align: "center" }, { title: "最高分", key: "best", @@ -149,6 +149,6 @@ const flowchartsColumns: DataTableColumn[] = [ align: "center", render: (row) => parseTime(row.latestSubmissionTime), }, - { title: "平均分", key: "avg_score", width: 100, align: "center" }, + { title: "平均分", key: "avgScore", width: 100, align: "center" }, ] diff --git a/apps/web/src/oj/problemset/components/UserProgressView.vue b/apps/web/src/oj/problemset/components/UserProgressView.vue index 39962fb..77ed79e 100644 --- a/apps/web/src/oj/problemset/components/UserProgressView.vue +++ b/apps/web/src/oj/problemset/components/UserProgressView.vue @@ -111,7 +111,7 @@ const progressColumns = [ title: "排名", key: "rank", width: 80, - render: (row: ProblemSetProgress, index: number) => { + render: (_row: ProblemSetProgress, index: number) => { // 计算全局排名:当前页偏移 + 当前行索引 + 1 const globalRank = (query.page - 1) * query.limit + index + 1 return globalRank @@ -132,7 +132,7 @@ const progressColumns = [ }, { title: "已完成数量", - key: "completed_problems_count", + key: "completedProblemsCount", width: 100, }, { diff --git a/apps/web/src/oj/rank/list.vue b/apps/web/src/oj/rank/list.vue index 08f9c28..8baab6f 100644 --- a/apps/web/src/oj/rank/list.vue +++ b/apps/web/src/oj/rank/list.vue @@ -295,28 +295,28 @@ const classColumns: DataTableColumn[] = [ }, { title: "人数", - key: "user_count", + key: "userCount", width: 80, titleAlign: "center", align: "center", }, { title: "总AC数", - key: "total_ac", + key: "totalAc", width: 90, titleAlign: "center", align: "center", }, { title: "提交数", - key: "total_submission", + key: "totalSubmission", width: 90, titleAlign: "center", align: "center", }, { title: "平均AC数", - key: "avg_ac", + key: "avgAc", width: 100, titleAlign: "center", align: "center", @@ -399,13 +399,13 @@ const myClassColumns: DataTableColumn[] = [ }, { title: "已解决", - key: "accepted_number", + key: "acceptedNumber", width: 120, align: "center", }, { title: "提交数", - key: "submission_number", + key: "submissionNumber", width: 120, align: "center", },