export interface ExplainCodeEntryTarget { code: string stopId: string hallName?: string } export const normalizeExplainCode = (code: string) => code.trim() export const explainCodeErrorMessage = (error: unknown) => { const code = error && typeof error === 'object' && 'code' in error ? Number((error as { code?: unknown }).code) : undefined if (code === 1020007000) return '请输入有效的 4 位讲解编号' if (code === 1020007001) return '未找到该讲解编号,请确认后重试' if (code === 1020007002) return '该编号的讲解内容暂不可用' if (code === 429) return '查询过于频繁,请稍后再试' return '编号查询失败,请检查网络后重试' } export const explainCodeDetailUrl = (target: ExplainCodeEntryTarget) => { const params = new URLSearchParams({ id: target.stopId, stopId: target.stopId, tab: 'explain', autoplay: '1', entry: 'code', guideCode: target.code }) if (target.hallName) params.set('hallName', target.hallName) return `/pages/exhibit/detail?${params.toString()}` }