fix: 补 .gitattributes(CRLF for .bat) + README 端口 19540 + 提交 console 锁文件

This commit is contained in:
AskaEth committed 2026-09-09 20:57:58 +08:00
1 parent c121111f51
commit b80c64a115
39 files changed
+4217 -345

No files matched your search

+20 -3
View File
@@ -69,7 +69,8 @@ async function call<T>(real: () => Promise<T>, mock: () => T | Promise<T>): Prom
}
export interface Bootstrap {
settings: EventSettings
/** settings 是 admin-only;访客/录入员读不到时为 null,其余赛事数据照常返回。 */
settings: EventSettings | null
teams: Team[]
sports: Sport[]
events: Event[]
@@ -78,11 +79,17 @@ export interface Bootstrap {
athleteStandings: AthleteStanding[]
}
/** 除 settings 外都视为必需:失败时交给 call 决定降级到示例数据还是抛出业务错误。 */
function required<T>(result: PromiseSettledResult<T>): T {
if (result.status === 'fulfilled') return result.value
throw result.reason
}
async function bootstrap(): Promise<Bootstrap> {
return call(
async () => {
const [settings, teams, sports, events, profiles, standings, athleteStandings] =
await Promise.all([
await Promise.allSettled([
client.settings.get(),
client.teams.list(),
client.sports.list(),
@@ -91,7 +98,17 @@ async function bootstrap(): Promise<Bootstrap> {
client.standings.teams(),
client.standings.athletes(),
])
return { settings, teams, sports, events, profiles, standings, athleteStandings }
// GET /api/settings 是 admin-only,guest/recorder 必然 403。
// 这是权限边界而非服务不可用,不能让整页数据跟着失败,所以 settings 单独降级为 null。
return {
settings: settings.status === 'fulfilled' ? settings.value : null,
teams: required(teams),
sports: required(sports),
events: required(events),
profiles: required(profiles),
standings: required(standings),
athleteStandings: required(athleteStandings),
}
},
() => mockDb.bootstrap(),
)