Some checks failed
Deploy / deploy (push) Has been cancelled
新增匿名可读的 GET /api/site/online,一条 ZCOUNT 让 Redis 自己数, 不拉成员、也不写(清理过期成员留给后台列表,匿名接口不带写操作)。 榜单页进页面拉一次,为 0 时不显示。 /rankings/users 的 isOnline 是三态:null 表示「这个调用方不该知道」, 只有老师及以上拿到 true/false。写成普通 boolean 的话学生看到的 false 和真的离线分不开,等于默认把每个人的在线状态摊给全校同学看。 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017xu912Rv5JUUuy6MqMcQW2
27 lines
794 B
TypeScript
27 lines
794 B
TypeScript
import { z } from "zod"
|
|
|
|
export const websiteConfigSchema = z.object({
|
|
websiteBaseUrl: z.string(),
|
|
websiteName: z.string(),
|
|
websiteNameShortcut: z.string(),
|
|
websiteFooter: z.string(),
|
|
allowRegister: z.boolean(),
|
|
submissionListShowAll: z.boolean(),
|
|
classList: z.array(z.string()),
|
|
enableMaxkb: z.boolean(),
|
|
})
|
|
|
|
/** 当前在线人数。只有聚合值 —— 「某某在不在线」是个人状态,不往匿名接口放 */
|
|
export const onlineCountSchema = z.object({
|
|
count: z.number().int().nonnegative(),
|
|
})
|
|
|
|
export const quoteSchema = z.union([
|
|
z.string(),
|
|
z.record(z.string(), z.unknown()),
|
|
])
|
|
|
|
export type WebsiteConfig = z.infer<typeof websiteConfigSchema>
|
|
export type Quote = z.infer<typeof quoteSchema>
|
|
export type OnlineCount = z.infer<typeof onlineCountSchema>
|