From 2e6e3aacec24bd589dbd63f22db44a5ea70a86a1 Mon Sep 17 00:00:00 2001 From: yuetsh <517252939@qq.com> Date: Sat, 2 May 2026 09:15:49 -0600 Subject: [PATCH] update --- src/pages/Gradebook.vue | 19 ++++++++++++++++--- src/utils/gradebook.ts | 12 ++++++++++++ 2 files changed, 28 insertions(+), 3 deletions(-) create mode 100644 src/utils/gradebook.ts diff --git a/src/pages/Gradebook.vue b/src/pages/Gradebook.vue index 1936bcd..b450242 100644 --- a/src/pages/Gradebook.vue +++ b/src/pages/Gradebook.vue @@ -94,6 +94,7 @@ import { } from "naive-ui" import { useRouter } from "vue-router" import { Account, Gradebook } from "../api" +import { displayGradebookStudentName } from "../utils/gradebook" import type { GradebookCell, GradebookOut, @@ -172,7 +173,11 @@ function renderTaskHeader(task: GradebookTask) { function renderScore(row: GradebookRow, task: GradebookTask) { const cell = row.scores[task.id] if (!cell || !cell.submitted) { - return h("span", { class: "missing-cell" }, "缺交") + return h( + NText, + { class: "missing-cell", type: "error" }, + { default: () => "缺交" }, + ) } return h( NButton, @@ -189,6 +194,11 @@ function renderScore(row: GradebookRow, task: GradebookTask) { ) } +function renderMissingCount(value: number) { + if (value <= 0) return "0" + return h(NText, { type: "error" }, { default: () => String(value) }) +} + const columns = computed[]>(() => { const tasks = gradebook.value?.tasks ?? [] return [ @@ -215,8 +225,10 @@ const columns = computed[]>(() => { key: "username", width: 140, fixed: "left", - render: (row) => - h(NText, { title: row.username }, { default: () => row.username }), + render: (row) => { + const studentName = displayGradebookStudentName(row) + return h(NText, { title: studentName }, { default: () => studentName }) + }, }, { title: "班级", @@ -271,6 +283,7 @@ const columns = computed[]>(() => { key: "missing_task_count", width: 70, fixed: "right", + render: (row) => renderMissingCount(row.missing_task_count), }, ] }) diff --git a/src/utils/gradebook.ts b/src/utils/gradebook.ts new file mode 100644 index 0000000..4e6a144 --- /dev/null +++ b/src/utils/gradebook.ts @@ -0,0 +1,12 @@ +export interface GradebookStudentIdentity { + username: string + classname: string +} + +export function displayGradebookStudentName(student: GradebookStudentIdentity) { + const generatedPrefix = `web${student.classname}` + if (!student.classname || !student.username.startsWith(generatedPrefix)) { + return student.username + } + return student.username.slice(generatedPrefix.length) +}