/** * 移动端底栏配置的单一事实源: * 与后端 service.MobileTabKeys 保持一致;管理面板、MobileTabBar、公共设置 normalize 共用。 * 配置为有序数组,数组顺序即前台底栏展示顺序;配置为空/非法回落默认全量。 */ export const MOBILE_TABS = ["home", "library", "compose", "messages", "me"] as const; export type MobileTabKey = (typeof MOBILE_TABS)[number]; /** 底栏默认全量配置 */ export const DEFAULT_MOBILE_TABS: MobileTabKey[] = [...MOBILE_TABS]; /** 配置子集解析:去空白、去重、只留白名单内元素;结果为空视为非法,回落默认全量 */ export function normalizeMobileTabs(raw: unknown): MobileTabKey[] { if (!Array.isArray(raw)) return [...DEFAULT_MOBILE_TABS]; const seen = new Set(); const out: MobileTabKey[] = []; for (const item of raw) { const key = String(item ?? "") .trim() .toLowerCase(); if (!key || seen.has(key)) continue; if (!(MOBILE_TABS as readonly string[]).includes(key)) continue; seen.add(key); out.push(key as MobileTabKey); } return out.length > 0 ? out : [...DEFAULT_MOBILE_TABS]; }