sync(theme-3): 同步 main 最新 API/Admin 与玩家端逻辑
从 main 同步站内信手动发送、媒体库选择、列表子路由重构等 API/Admin 改动;玩家端仅合并 ADMIN_CUSTOM 富文本、消息预览与充值截图压缩逻辑,保留 theme-3 样式。
This commit is contained in:
@@ -1,10 +1,8 @@
|
||||
/** 赛事列表 UI 状态(返回列表时恢复展开等) */
|
||||
/** 赛事列表 UI 状态(返回列表时恢复筛选与分页) */
|
||||
|
||||
const STORAGE_KEY = 'admin_matches_list_ui';
|
||||
export const MAX_EXPANDED_LEAGUES = 3;
|
||||
|
||||
export type MatchesListUiState = {
|
||||
expandedLeagueIds: string[];
|
||||
page: number;
|
||||
pageSize: number;
|
||||
filterStatus: string;
|
||||
@@ -13,7 +11,6 @@ export type MatchesListUiState = {
|
||||
|
||||
function defaultState(): MatchesListUiState {
|
||||
return {
|
||||
expandedLeagueIds: [],
|
||||
page: 1,
|
||||
pageSize: 10,
|
||||
filterStatus: '',
|
||||
@@ -21,44 +18,21 @@ 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,
|
||||
expandedLeagueIds: capExpanded(parsed.expandedLeagueIds),
|
||||
};
|
||||
return JSON.parse(raw) as MatchesListUiState;
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
export function writeMatchesListUiState(state: MatchesListUiState) {
|
||||
sessionStorage.setItem(
|
||||
STORAGE_KEY,
|
||||
JSON.stringify({
|
||||
...state,
|
||||
expandedLeagueIds: capExpanded(state.expandedLeagueIds),
|
||||
}),
|
||||
);
|
||||
sessionStorage.setItem(STORAGE_KEY, JSON.stringify(state));
|
||||
}
|
||||
|
||||
export function patchMatchesListUiState(patch: Partial<MatchesListUiState>) {
|
||||
const base = readMatchesListUiState() ?? defaultState();
|
||||
writeMatchesListUiState({ ...base, ...patch });
|
||||
}
|
||||
|
||||
/** 从子页返回前确保该赛事行处于展开记录中 */
|
||||
export function ensureLeagueExpanded(leagueId: string) {
|
||||
if (!leagueId) return;
|
||||
const base = readMatchesListUiState() ?? defaultState();
|
||||
const ids = capExpanded([...new Set([...base.expandedLeagueIds, leagueId])]);
|
||||
writeMatchesListUiState({ ...base, expandedLeagueIds: ids });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user