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
@@ -1,7 +1,7 @@
|
||||
import { TIME_ZONE_OFFSET_MINUTES, toAdminType } from "@oj2/contract"
|
||||
import type { JudgeCaseResult, JudgeInfo } from "@oj2/contract"
|
||||
import { getTime, intervalToDuration, parseISO, type Duration } from "date-fns"
|
||||
import { Submission, User } from "./types"
|
||||
import { AdminUser, Submission } from "./types"
|
||||
import { JUDGE_STATUS, USER_TYPE } from "./constants"
|
||||
import {
|
||||
strFromU8,
|
||||
@@ -283,7 +283,7 @@ export function debounce<T extends (...args: any[]) => any>(
|
||||
}
|
||||
}
|
||||
|
||||
export function getUserRole(role: User["adminType"]): {
|
||||
export function getUserRole(role: AdminUser["adminType"]): {
|
||||
type: "default" | "info" | "warning" | "error"
|
||||
label: "普通" | "生管" | "师管" | "超管"
|
||||
} {
|
||||
@@ -315,7 +315,7 @@ export function unique<T>(arr: T[]): T[] {
|
||||
return [...new Set(arr)]
|
||||
}
|
||||
|
||||
export function encode(string?: string): string {
|
||||
export function base64EncodeUtf8(string?: string): string {
|
||||
try {
|
||||
return btoa(String.fromCharCode(...new TextEncoder().encode(string ?? "")))
|
||||
} catch (error) {
|
||||
@@ -324,7 +324,7 @@ export function encode(string?: string): string {
|
||||
}
|
||||
}
|
||||
|
||||
export function decode(bytes?: string): string {
|
||||
export function base64DecodeUtf8(bytes?: string): string {
|
||||
try {
|
||||
if (!bytes) return ""
|
||||
const latin = atob(bytes)
|
||||
@@ -339,14 +339,14 @@ export function decode(bytes?: string): string {
|
||||
}
|
||||
}
|
||||
|
||||
export function utoa(data: string): string {
|
||||
export function compressToBase64(data: string): string {
|
||||
const buffer = strToU8(data)
|
||||
const zipped = zlibSync(buffer, { level: 9 })
|
||||
const binary = strFromU8(zipped, true)
|
||||
return btoa(binary)
|
||||
}
|
||||
|
||||
export function atou(base64: string): string {
|
||||
export function decompressFromBase64(base64: string): string {
|
||||
const binary = atob(base64)
|
||||
const buffer = strToU8(binary, true)
|
||||
const unzipped = unzlibSync(buffer)
|
||||
|
||||
Reference in new issue
Block a user