refactor: 一批名不副实的命名改掉(只动一端,不碰契约)
后端: - getUserByToken → authenticateToken:它会删会话、续 TTL、记在线,不是纯读 - todayStart → dayStart(instant):本来就接受任意时刻,不只是「今天」 - objectValue → asRecord,删掉 4 份一模一样的私有拷贝和 `as toObject` 别名 - 报错文案 "does not exists" / "Already be a public problem" 改通顺 前端: - utils/types 里 Contest / User / Problem 三个别名删掉:Contest 原来指后台 比赛、契约里同名的却是学生侧。现在 Contest = 学生侧、AdminContest = 后台, 后台用户表单叫 AdminUserForm,题目详情直接用 ProblemDetail - SubmissionInfo → ContestSubmissionInfo,免得和 submission.info 撞名 - utoa / atou → compressToBase64 / decompressFromBase64(实际是 zlib + base64), encode / decode → base64EncodeUtf8 / base64DecodeUtf8 - filterResult → toProblemRow、toProblemListItem → toAdminProblemRow, 行字段 submission / rate → submissionCount / acRate - 组件:Modal → AddFromLibraryModal、Form → EditorToolbar、 ContestEditor → BasicEditor(题单也在用它)、rank 的 Index → RankMedal、 Name → UserNameCell、Password → PasswordCell、ContestType → ContestAccessTag Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
572a818d49
commit
5ae830a7f9
62 files changed
+284
-320
No files matched your search
+15
-15
@@ -1,5 +1,5 @@
|
||||
import api from "utils/api"
|
||||
import { toProblemListItem } from "admin/transforms"
|
||||
import { toAdminProblemRow } from "admin/transforms"
|
||||
import type {
|
||||
AcTrend,
|
||||
AdminProblemSetProgress,
|
||||
@@ -8,7 +8,7 @@ import type {
|
||||
RenameTagResponse,
|
||||
SqlTestCaseScript,
|
||||
AcmHelperItem,
|
||||
SubmissionInfo,
|
||||
ContestSubmissionInfo,
|
||||
AdminAiReport,
|
||||
AdminAiReportList,
|
||||
StuckProblem,
|
||||
@@ -30,13 +30,13 @@ import type {
|
||||
AdminAnnouncementListItem,
|
||||
BlankContest,
|
||||
BlankProblem,
|
||||
Contest,
|
||||
AdminContest,
|
||||
Exercise,
|
||||
ExerciseType,
|
||||
SqlDisplay,
|
||||
UploadTestCaseResponse,
|
||||
Tutorial,
|
||||
User,
|
||||
AdminUserForm,
|
||||
WebsiteConfig,
|
||||
AdminProblemSetBadge,
|
||||
AdminProblemSetList,
|
||||
@@ -70,7 +70,7 @@ export async function getProblemList(
|
||||
params: { offset, limit, keyword, author, tagId },
|
||||
})
|
||||
return {
|
||||
results: res.results.map(toProblemListItem),
|
||||
results: res.results.map(toAdminProblemRow),
|
||||
total: res.total,
|
||||
}
|
||||
}
|
||||
@@ -165,7 +165,7 @@ export function getUserList(
|
||||
}
|
||||
|
||||
// 编辑用户
|
||||
export function editUser(user: User) {
|
||||
export function editUser(user: AdminUserForm) {
|
||||
return api.put<AdminUser>(`admin/users/${user.id}`, {
|
||||
username: user.username,
|
||||
email: user.email,
|
||||
@@ -297,7 +297,7 @@ export function createContestProblem(problem: BlankProblem) {
|
||||
}
|
||||
|
||||
/** 组件里的比赛对象是 snake_case,出站转成新后端要的 camelCase */
|
||||
function toContestBody(contest: Contest | BlankContest) {
|
||||
function toContestBody(contest: AdminContest | BlankContest) {
|
||||
return {
|
||||
title: contest.title,
|
||||
description: contest.description,
|
||||
@@ -310,22 +310,22 @@ function toContestBody(contest: Contest | BlankContest) {
|
||||
}
|
||||
|
||||
export function createContest(contest: BlankContest) {
|
||||
return api.post<Contest>("admin/contests", toContestBody(contest))
|
||||
return api.post<AdminContest>("admin/contests", toContestBody(contest))
|
||||
}
|
||||
|
||||
export function editContest(contest: Contest | BlankContest) {
|
||||
return api.put<Contest>(
|
||||
`admin/contests/${(contest as Contest).id}`,
|
||||
export function editContest(contest: AdminContest | BlankContest) {
|
||||
return api.put<AdminContest>(
|
||||
`admin/contests/${(contest as AdminContest).id}`,
|
||||
toContestBody(contest),
|
||||
)
|
||||
}
|
||||
|
||||
export function cloneContest(contestId: number) {
|
||||
return api.post<Contest>(`admin/contests/${contestId}/clone`)
|
||||
return api.post<AdminContest>(`admin/contests/${contestId}/clone`)
|
||||
}
|
||||
|
||||
export function getContest(id: string) {
|
||||
return api.get<Contest>(`admin/contests/${id}`)
|
||||
return api.get<AdminContest>(`admin/contests/${id}`)
|
||||
}
|
||||
|
||||
export function addProblemForContest(
|
||||
@@ -463,9 +463,9 @@ export function makeProblemPublic(id: number, displayId: string) {
|
||||
// 比赛辅助检查
|
||||
export function getACMHelperList(contestId: number) {
|
||||
// acInfo 在契约里是 Record<string, unknown>(acm_contest_rank 的 JSONB 原文),
|
||||
// 组件侧按 SubmissionInfo 读,收窄放在这里
|
||||
// 组件侧按 ContestSubmissionInfo 读,收窄放在这里
|
||||
return api.get<
|
||||
Array<Omit<AcmHelperItem, "acInfo"> & { acInfo: SubmissionInfo }>
|
||||
Array<Omit<AcmHelperItem, "acInfo"> & { acInfo: ContestSubmissionInfo }>
|
||||
>(`admin/contests/${contestId}/acm-helper`)
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user