fix(名字): 比赛成绩、全班情况、看板、题单、统计里的名字不再用真名,一律和排行榜一样显示 ks241XXX;导出成绩去掉姓名列
Deploy / deploy (push) Canceled after 0s

两个写法不同的 UserName 合成 shared/components/UserName.vue 一个。

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
xuyueandClaude Opus 5.5 committed 2026-10-10 06:44:42 +08:00
1 parent 2bb74652a0
commit 0cee4ef779
10 files changed
+44 -88

No files matched your search

+5 -3
View File
@@ -1,5 +1,6 @@
<script setup lang="ts">
import { getClassBoard, setClassLesson } from "oj/api"
import UserName from "shared/components/UserName.vue"
import { useLeaveStudents } from "shared/composables/leaveStudents"
import { useCollabStore } from "shared/store/collab"
import { useConfigStore } from "shared/store/config"
@@ -159,8 +160,9 @@ const GROUP_ORDER: Record<Group, number> = {
leave: 5,
}
/** 名字和别处一样用用户名(ks241XXX),不用真名 */
function nameOf(student: ClassBoardStudent) {
return student.realName || student.username
return student.username
}
/**
@@ -491,9 +493,9 @@ function submissionsHref(
target="_blank"
:title="`看 ${nameOf(student)} 今天交的全部`"
>
{{ nameOf(student) }}
<UserName :username="student.username" />
</a>
<template v-else>{{ nameOf(student) }}</template>
<UserName v-else :username="student.username" />
</td>
<td>
<n-tag
@@ -3,7 +3,7 @@ import type { ContestScoreRow } from "@oj2/contract"
import { useThemeVars } from "naive-ui"
import { useTone } from "oj/submission/composables/tone"
import { secondsToDuration } from "utils/functions"
import UserName from "./UserName.vue"
import UserName from "shared/components/UserName.vue"
/**
* 题目页右边的小榜:前三名,然后是我和我前后各两个人(中间隔一个「⋯」)。
@@ -42,12 +42,7 @@ function move(row: ContestScoreRow) {
><span class="down">↓{{ -move(row) }}</span></template
>
</span>
<UserName
class="who"
:username="row.username"
:class-name="row.className"
:strong="row.userId === me"
/>
<UserName class="who" :username="row.username" />
<span class="solved">{{ row.solved }} 道</span>
<span class="time">{{ secondsToDuration(row.totalTime) }}</span>
</div>
+12 -29
View File
@@ -4,6 +4,7 @@ import { useThemeVars } from "naive-ui"
import { updateACMHelperChecked } from "admin/api"
import { getContestClassView, getSubmission, getSubmissions } from "oj/api"
import { useContestStore } from "oj/store/contest"
import UserName from "shared/components/UserName.vue"
import { useTone } from "oj/submission/composables/tone"
import { classLabel } from "oj/submission/utils"
import { useLeaveStudents } from "shared/composables/leaveStudents"
@@ -14,7 +15,8 @@ import type { Submission } from "utils/types"
/**
* 老师的「全班情况」,考完叫「成绩」(设计稿「比赛重设计」老师两块)。学生看不到这一页。
*
* 考试中:真名,卡在一道题(错 3 次以上)和 15 分钟以上没交的人放最上面,
* 名字和排行榜一样用用户名(ks241XXX),不用真名。
* 考试中:卡在一道题(错 3 次以上)和 15 分钟以上没交的人放最上面,
* 没进来的人在最下面(看板里标了请假的写「请假」)。
* 考完:按姓名一张表,点格子右边看代码、标「看过了」(代替原来后台的「审核」页),导出成绩。
* 名单是推出来的:比赛不绑班,来了一半以上的班才算这场的班(后端 buildClassView)
@@ -270,7 +272,6 @@ function exportGrades() {
const title = contestStore.contest?.title ?? "比赛"
const head = [
"用户名",
"姓名",
"班级",
"做对",
"名次",
@@ -282,7 +283,6 @@ function exportGrades() {
for (const row of byUsername) {
lines.push([
row.username,
row.realName ?? "",
row.className ? classLabel(row.className) : "",
String(row.solved),
String(row.rank ?? ""),
@@ -296,7 +296,6 @@ function exportGrades() {
for (const user of absent.value) {
lines.push([
user.username,
user.realName ?? "",
user.className ? classLabel(user.className) : "",
user.leave ? "请假" : "没考",
"",
@@ -323,7 +322,7 @@ const warning = computed(() => tone("warning"))
const liveColumns = computed(
() => `116px 44px repeat(${problems.value.length}, minmax(64px, 92px)) 82px 1fr`,
)
const gradeColumns = computed(() => `22px 70px 36px 34px repeat(${problems.value.length}, 46px)`)
const gradeColumns = computed(() => `22px 110px 36px 34px repeat(${problems.value.length}, 46px)`)
</script>
<template>
@@ -385,10 +384,7 @@ const gradeColumns = computed(() => `22px 70px 36px 34px repeat(${problems.value
class="tr"
:style="{ gridTemplateColumns: liveColumns }"
>
<span class="who">
<b class="ell">{{ row.realName || row.username }}</b>
<span class="ell muted tiny">{{ row.username }}</span>
</span>
<UserName :username="row.username" />
<span class="num solved">{{ row.solved }}</span>
<span v-for="p in problems" :key="p.id" class="lc">
<template v-if="cellOf(row, p.id)">
@@ -418,10 +414,7 @@ const gradeColumns = computed(() => `22px 70px 36px 34px repeat(${problems.value
class="tr"
:style="{ gridTemplateColumns: liveColumns }"
>
<span class="who">
<b class="ell">{{ row.realName || row.username }}</b>
<span class="ell muted tiny">{{ row.username }}</span>
</span>
<UserName :username="row.username" />
<span class="num solved">{{ row.solved }}</span>
<span v-for="p in problems" :key="p.id" class="lc">
<template v-if="cellOf(row, p.id)">
@@ -449,10 +442,7 @@ const gradeColumns = computed(() => `22px 70px 36px 34px repeat(${problems.value
class="tr absent"
:style="{ gridTemplateColumns: liveColumns }"
>
<span class="who">
<span class="ell">{{ user.realName || user.username }}</span>
<span class="ell tiny">{{ user.username }}</span>
</span>
<UserName :username="user.username" muted />
<span></span>
<span v-for="p in problems" :key="p.id"></span>
<span></span>
@@ -510,7 +500,7 @@ const gradeColumns = computed(() => `22px 70px 36px 34px repeat(${problems.value
<div class="sheet-scroll">
<div class="tr th" :style="{ gridTemplateColumns: gradeColumns }">
<span></span>
<span>姓名</span>
<span>学生</span>
<span class="num">做对</span>
<span class="num">名次</span>
<span v-for="p in problems" :key="p.id" class="ph center" :title="p.title">
@@ -526,7 +516,7 @@ const gradeColumns = computed(() => `22px 70px 36px 34px repeat(${problems.value
:style="{ gridTemplateColumns: gradeColumns }"
>
<span class="muted tiny num">{{ index + 1 }}</span>
<b class="ell" :title="row.username">{{ row.realName || row.username }}</b>
<UserName :username="row.username" />
<span class="num solved">{{ row.solved }}</span>
<span class="num muted tiny">{{ row.rank }}</span>
<button
@@ -538,7 +528,7 @@ const gradeColumns = computed(() => `22px 70px 36px 34px repeat(${problems.value
no: cellOf(row, p.id) && !cellOf(row, p.id)!.isAc,
sel: selected?.userId === row.userId && selected.problemId === p.id,
}"
:title="`${row.realName || row.username} · 第 ${p._id} 题`"
:title="`${row.username} · 第 ${p._id} 题`"
@click="pick(row, p.id)"
>
<template v-if="cellOf(row, p.id)?.isAc">✓</template>
@@ -554,7 +544,7 @@ const gradeColumns = computed(() => `22px 70px 36px 34px repeat(${problems.value
:style="{ gridTemplateColumns: gradeColumns }"
>
<span></span>
<span class="ell">{{ user.realName || user.username }}</span>
<UserName :username="user.username" muted />
<span class="tiny">{{ user.leave ? "请假" : "没考" }}</span>
</div>
</div>
@@ -563,7 +553,7 @@ const gradeColumns = computed(() => `22px 70px 36px 34px repeat(${problems.value
<section class="code-panel">
<template v-if="selectedRow && selectedProblem">
<div class="code-head">
<b>{{ selectedRow.realName || selectedRow.username }}</b>
<UserName :username="selectedRow.username" />
<span class="muted">·</span>
<span
><span class="muted">{{ selectedProblem._id }}</span>
@@ -735,13 +725,6 @@ const gradeColumns = computed(() => `22px 70px 36px 34px repeat(${problems.value
font-size: 11px;
}
.who {
display: flex;
flex-direction: column;
line-height: 16px;
min-width: 0;
}
.solved {
font-weight: 700;
padding-right: 10px;
+3 -14
View File
@@ -7,7 +7,7 @@ import { useUserStore } from "shared/store/user"
import { ContestStatus } from "utils/constants"
import { secondsToDuration } from "utils/functions"
import { classLabel } from "oj/submission/utils"
import UserName from "../components/UserName.vue"
import UserName from "shared/components/UserName.vue"
/**
* 比赛排名(设计稿「比赛重设计」排行榜两块)。竞争感是用户要的(「我需要竞争」):
@@ -136,12 +136,7 @@ const columns = computed(
<path d="M8 20h8" />
</svg>
<template v-if="podium[place - 1]">
<UserName
class="podium-name"
:username="podium[place - 1]!.username"
:class-name="podium[place - 1]!.className"
strong
/>
<UserName class="podium-name" :username="podium[place - 1]!.username" />
<span class="muted small">
{{ classLabel(podium[place - 1]!.className) }} · {{ podium[place - 1]!.solved }} 道 ·
{{ secondsToDuration(podium[place - 1]!.totalTime) }}
@@ -220,13 +215,7 @@ const columns = computed(
<span v-if="move(row) > 0" class="up">↑{{ move(row) }}</span>
<span v-else-if="move(row) < 0" class="down">↓{{ -move(row) }}</span>
</span>
<UserName
class="pad"
:username="row.username"
:class-name="row.className"
:strong="row.userId === meId"
:title="row.realName ?? row.username"
/>
<UserName class="pad" :username="row.username" />
<span class="num solved">{{ row.solved }}</span>
<span class="num time">{{ secondsToDuration(row.totalTime) }}</span>
<span v-for="p in problems" :key="p.id" class="cell-wrap">
@@ -2,6 +2,7 @@
import { useThemeVars } from "naive-ui"
import { getProblemSetClassView } from "oj/api"
import { useTone } from "oj/submission/composables/tone"
import UserName from "shared/components/UserName.vue"
import { parseTime } from "utils/functions"
import type { ProblemSetClassView } from "utils/types"
@@ -60,13 +61,9 @@ const beforeCount = computed(() =>
)
const columns = computed(
() => `22px 72px 44px repeat(${data.value?.problems.length ?? 1}, minmax(72px, 1fr))`,
() => `22px 110px 44px repeat(${data.value?.problems.length ?? 1}, minmax(72px, 1fr))`,
)
function name(student: { realName: string | null; username: string }) {
return student.realName || student.username
}
function cellLink(username: string, problemId: string) {
return `/submission?username=${encodeURIComponent(username)}&problem=${encodeURIComponent(problemId)}`
}
@@ -105,8 +102,11 @@ const error = computed(() => tone("error"))
><span class="muted">做完</span> <b class="num big">{{ finished }}</b
><span class="muted"> 人</span></span
>
<span v-if="absent.length" class="absent ell" :title="absent.map(name).join('、')"
>没加入:{{ absent.map(name).join("、") }}</span
<span
v-if="absent.length"
class="absent ell"
:title="absent.map((s) => s.username).join('、')"
>没加入:{{ absent.map((s) => s.username).join("、") }}</span
>
<div class="spacer"></div>
<span v-if="beforeCount" class="legend-before"
@@ -117,7 +117,7 @@ const error = computed(() => tone("error"))
<div class="scroll">
<div class="grid" :style="{ gridTemplateColumns: columns }">
<div class="head"></div>
<div class="head">姓名</div>
<div class="head">学生</div>
<div class="head right">做对</div>
<div v-for="(p, i) in data.problems" :key="p.id" class="head col" :title="p.title">
<b class="ell">{{ i + 1 }} {{ p.title }}</b>
@@ -128,8 +128,8 @@ const error = computed(() => tone("error"))
<template v-for="(s, idx) in joined" :key="s.userId">
<div class="cell muted num tiny">{{ idx + 1 }}</div>
<div class="cell ell" :title="s.username">
<b>{{ name(s) }}</b>
<div class="cell ell">
<UserName :username="s.username" />
</div>
<div class="cell right num">
<b>{{ s.completedCount }}</b>
@@ -141,7 +141,7 @@ const error = computed(() => tone("error"))
target="_blank"
class="box"
:class="{ ok: c.solvedTime, bad: !c.solvedTime && c.wrongCount }"
:title="`${name(s)} · ${data.problems[i]!.title}${c.solvedBefore ? ' · 加入前就做对过' : ''}`"
:title="`${s.username} · ${data.problems[i]!.title}${c.solvedBefore ? ' · 加入前就做对过' : ''}`"
>
<template v-if="c.solvedTime"
>✓ <span class="num">{{ cellTime(c.solvedTime) }}</span></template
@@ -6,6 +6,7 @@ import { SubmissionStatus } from "utils/constants"
import { parseTime } from "utils/functions"
import StatusPill from "oj/submission/components/StatusPill.vue"
import { useTone } from "oj/submission/composables/tone"
import UserName from "shared/components/UserName.vue"
import AttemptSquares from "./AttemptSquares.vue"
/**
@@ -42,7 +43,6 @@ function isPending(result: number) {
interface Student {
username: string
name: string
/** 题号 → 这道题上的每一次,从早到晚 */
byProblem: Map<string, Attempt[]>
total: number
@@ -63,7 +63,6 @@ const students = computed<Student[]>(() => {
}
return {
username: row.username,
name: row.realName || row.username,
byProblem,
total: row.submissions.length,
accepted: row.submissions.filter((item) => isAc(item.result)).length,
@@ -76,7 +75,6 @@ const students = computed<Student[]>(() => {
if (seen.has(row.username)) continue
list.push({
username: row.username,
name: row.realName || row.username,
byProblem: new Map(),
total: 0,
accepted: 0,
@@ -168,7 +166,7 @@ const problemStudents = computed(() => {
(a, b) =>
rank(a) - rank(b) ||
b.items.length - a.items.length ||
a.student.name.localeCompare(b.student.name, "zh-CN"),
a.student.username.localeCompare(b.student.username, "zh-CN"),
)
})
@@ -188,7 +186,7 @@ const allStudents = computed(() => {
(a, b) =>
rank(a) - rank(b) ||
b.student.total - a.student.total ||
a.student.name.localeCompare(b.student.name, "zh-CN"),
a.student.username.localeCompare(b.student.username, "zh-CN"),
)
})
@@ -326,7 +324,7 @@ function pct(done: number, total: number) {
</div>
<div class="rows">
<div v-for="row in problemStudents" :key="row.student.username" class="row">
<span class="c-name name" :title="row.student.username">{{ row.student.name }}</span>
<UserName :username="row.student.username" class="c-name" />
<span class="c-last">
<StatusPill v-if="row.items.length" :result="row.items.at(-1)!.result" />
<b v-else class="none" :style="{ color: tone('error').color }">没交</b>
@@ -369,7 +367,7 @@ function pct(done: number, total: number) {
:width="12"
/>
</span>
<span class="c-name name" :title="row.student.username">{{ row.student.name }}</span>
<UserName :username="row.student.username" class="c-name" />
<span
class="c-done done"
:style="{
@@ -691,13 +689,6 @@ function pct(done: number, total: number) {
white-space: nowrap;
}
.name {
font-weight: 600;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.done {
font-weight: 600;
font-variant-numeric: tabular-nums;
@@ -21,6 +21,7 @@ import { FLOWCHART_CRITERIA_ORDER } from "utils/constants"
import { useTone } from "oj/submission/composables/tone"
import RingChart from "./RingChart.vue"
import StatItem from "./StatItem.vue"
import UserName from "shared/components/UserName.vue"
ChartJS.register(
ArcElement,
@@ -198,14 +199,12 @@ onUnmounted(() => cloud?.destroy())
const people = computed(() => [
...props.data.dataUnaccepted.map((row) => ({
username: row.username,
name: row.realName,
grade: null as string | null,
score: null as number | null,
count: 0,
})),
...props.data.people.map((row) => ({
username: row.username,
name: row.realName,
grade: row.bestGrade,
score: row.bestScore,
count: row.count,
@@ -290,7 +289,7 @@ function gradeStyle(grade: string | null) {
<div v-if="data.peopleTruncated" class="muted">人太多,只列了成绩靠后的 500 位</div>
<div class="people-list">
<div v-for="row in people" :key="row.username" class="person">
<b class="p-name" :title="row.username">{{ row.name }}</b>
<UserName :username="row.username" class="p-name" />
<span class="grade-pill" :style="gradeStyle(row.grade)">
{{ row.grade ? `${row.grade} 级 ${row.score ?? 0} 分` : "没交" }}
</span>
@@ -421,11 +420,8 @@ function gradeStyle(grade: string | null) {
}
.p-name {
width: 80px;
width: 110px;
flex: none;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.grade-pill {
@@ -9,7 +9,7 @@ import { FlowchartSubmissionStatus } from "utils/types"
import { useTone } from "../composables/tone"
import { submissionTimeText } from "../utils"
import FlowchartState from "./FlowchartState.vue"
import UserName from "./UserName.vue"
import UserName from "shared/components/UserName.vue"
/**
* 流程图模式的右栏:左边画出来的图,右边四项评分和建议。原来要点编号再开一个
@@ -20,7 +20,7 @@ import { useTone } from "../composables/tone"
import { classLabel, submissionTimeText } from "../utils"
import CodeView from "./CodeView.vue"
import StatusPill from "./StatusPill.vue"
import UserName from "./UserName.vue"
import UserName from "shared/components/UserName.vue"
/**
* 提交列表的右栏:选中那一条的代码和结果(设计稿「提交列表重设计 · 定稿」)。
+1 -1
View File
@@ -29,7 +29,7 @@ import type {
import { FlowchartSubmissionStatus } from "utils/types"
import FlowchartState from "./components/FlowchartState.vue"
import StatusPill from "./components/StatusPill.vue"
import UserName from "./components/UserName.vue"
import UserName from "shared/components/UserName.vue"
import { useTone } from "./composables/tone"
import { classLabel, classSelectOptions, submissionClockText, submissionDayText } from "./utils"