feat: WC2026 赛事 seed、生产上线初始化脚本与目录归档
重构 seed 为 WC2026 72 场小组赛与 48 强优胜盘;新增 production 模式仅保留 admin 与赛事示例;提供 prod-init-db 全量重置脚本;管理端 i18n 分包与赛事归档能力。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
/** 赛事列表 UI 状态(返回列表时恢复展开等) */
|
||||
|
||||
const STORAGE_KEY = 'admin_matches_list_ui';
|
||||
export const MAX_EXPANDED_LEAGUES = 3;
|
||||
|
||||
export type MatchesListUiState = {
|
||||
expandedLeagueIds: string[];
|
||||
@@ -20,20 +21,33 @@ function defaultState(): MatchesListUiState {
|
||||
};
|
||||
}
|
||||
|
||||
function capExpanded(ids: string[]): string[] {
|
||||
return ids.slice(0, MAX_EXPANDED_LEAGUES);
|
||||
}
|
||||
|
||||
export function readMatchesListUiState(): MatchesListUiState | null {
|
||||
try {
|
||||
const raw = sessionStorage.getItem(STORAGE_KEY);
|
||||
if (!raw) return null;
|
||||
const parsed = JSON.parse(raw) as MatchesListUiState;
|
||||
if (!Array.isArray(parsed.expandedLeagueIds)) return null;
|
||||
return parsed;
|
||||
return {
|
||||
...parsed,
|
||||
expandedLeagueIds: capExpanded(parsed.expandedLeagueIds),
|
||||
};
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
export function writeMatchesListUiState(state: MatchesListUiState) {
|
||||
sessionStorage.setItem(STORAGE_KEY, JSON.stringify(state));
|
||||
sessionStorage.setItem(
|
||||
STORAGE_KEY,
|
||||
JSON.stringify({
|
||||
...state,
|
||||
expandedLeagueIds: capExpanded(state.expandedLeagueIds),
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
export function patchMatchesListUiState(patch: Partial<MatchesListUiState>) {
|
||||
@@ -45,7 +59,6 @@ export function patchMatchesListUiState(patch: Partial<MatchesListUiState>) {
|
||||
export function ensureLeagueExpanded(leagueId: string) {
|
||||
if (!leagueId) return;
|
||||
const base = readMatchesListUiState() ?? defaultState();
|
||||
const ids = new Set(base.expandedLeagueIds);
|
||||
ids.add(leagueId);
|
||||
writeMatchesListUiState({ ...base, expandedLeagueIds: [...ids] });
|
||||
const ids = capExpanded([...new Set([...base.expandedLeagueIds, leagueId])]);
|
||||
writeMatchesListUiState({ ...base, expandedLeagueIds: ids });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user