const Routes = { 'patient_file': /* 建档页 */ '/register', 'tongueface_upload': /*拍照页*/ '/camera', 'tongueface_upload_result': /* [虚拟] 拍照结果页 */ '/camera/result', 'tongueface_analysis': /* 问卷页 */ '/questionnaire', 'tongueface_analysis_result': /* 舌面象分析报告页 */ '/report/analysis', 'health_analysis': /* 健康报告页 */ '/report', 'pulse_upload': /* 脉诊页 */ '/pulse', 'pulse_upload_result': /* 脉诊结果页 */ '/pulse/result', 'screen': '/screen', } as const; export interface Flow { route: string; title?: string; optional?: boolean; } export function fromFlowData(options: string[]): Map { const ref = new Map(); const length = options.length; // 修正虚拟路由 const k1 = 'tongueface_upload'; const k2 = 'tongueface_upload_result'; if ( !options.includes(k2) && options[ length - 1 ] === k1 ) options.push(k2); options.unshift('/screen'); options.push('screen'); for ( let i = 1; i < options.length; i++ ) { const path = options[i]; const optional = path.includes('?'); const [name, title] = path.split('?'); const route = (options[i] = getPath(name)); ref.set(options[i - 1], { route, optional, title, }); } return ref; } export function getPath(value?: string) { return Routes[ value as keyof typeof Routes ]; }