refactor(前端): 去掉 nanoid 和 date-fns;「12月」这种时长改说「1年」,年月按东八区日历数
Deploy / deploy (push) Canceled after 0s

时长拆分(比赛倒计时、比赛时长、主页「最近一次提交」)改用自己写的东八区日历差,
和 zonedParts 同一个口径,不再跟浏览器时区走。顺手删掉几次重设计后已经没人用的
getRandomId、durationFromValue 和 DURATION_OPTIONS / LONG_DURATION_OPTIONS。

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
xuyueandClaude Opus 5.5 committed 2026-10-20 19:47:34 +08:00
1 parent d6c3171d13
commit a2dcafae14
5 files changed
+54 -80

No files matched your search

-25
View File
@@ -311,31 +311,6 @@ export function sortFlowchartCriteria<T>(details: Record<string, T>): [string, T
return Object.entries(details).sort(([a], [b]) => rank(a) - rank(b))
}
/**
* 时段选项。`value` 是 `<date-fns 的单位>:<数量>`,由 `durationFromValue()` 解析 ——
* 别在组件里再手写一遍 `split(":")`,那套解析原来散在五个文件里。
*/
export const DURATION_OPTIONS = [
{ label: "本节课内", value: "hours:1" },
{ label: "两节课内", value: "hours:2" },
{ label: "一天内", value: "days:1" },
{ label: "一周内", value: "weeks:1" },
{ label: "一个月内", value: "months:1" },
{ label: "两个月内", value: "months:2" },
{ label: "半年内", value: "months:6" },
{ label: "一年内", value: "years:1" },
] as const
/**
* 班级对比用的长时段,一周起步。
*
* 看的是长期趋势,「本节课内」这种窗口在那儿没有意义 —— 全班一小时内的
* AC 数拉出来比不出什么。从上面那份派生,不另抄一份。
*/
export const LONG_DURATION_OPTIONS = DURATION_OPTIONS.filter(
(option) => !["hours:1", "hours:2", "days:1"].includes(option.value),
)
// 班级号的位数范围。学生用户名形如 ks<班级号><姓名>,班级号还要跟
// 网站配置里的班级列表对得上。
// 后端 OnlineJudge/utils/shortcuts.py 的 CLASS_NAME_MIN/MAX_DIGITS