flow.model.ts 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. const Routes = {
  2. 'patient_file': /* 建档页 */ '/register',
  3. 'tongueface_upload': /*拍照页*/ '/camera',
  4. 'tongueface_upload_result': /* [虚拟] 拍照结果页 */ '/camera/result',
  5. 'tongueface_analysis': /* 问卷页 */ '/questionnaire',
  6. 'tongueface_analysis_result': /* 舌面象分析报告页 */ '/report/analysis',
  7. 'health_analysis': /* 健康报告页 */ '/report',
  8. 'pulse_upload': /* 脉诊页 */ '/pulse',
  9. 'pulse_upload_result': /* 脉诊结果页 */ '/pulse/result',
  10. 'screen': '/screen',
  11. } as const;
  12. export interface Flow {
  13. route: string;
  14. title?: string;
  15. optional?: boolean;
  16. }
  17. export function fromFlowData(options: string[]): Map<string, Flow> {
  18. const ref = new Map<string, Flow>();
  19. const length = options.length;
  20. // 修正虚拟路由
  21. const k1 = 'tongueface_upload';
  22. const k2 = 'tongueface_upload_result';
  23. if ( !options.includes(k2) && options[ length - 1 ] === k1 ) options.push(k2);
  24. options.unshift('/screen');
  25. options.push('screen');
  26. for ( let i = 1; i < options.length; i++ ) {
  27. const path = options[i];
  28. const optional = path.includes('?');
  29. const [name, title] = path.split('?');
  30. const route = (options[i] = getPath(name));
  31. ref.set(options[i - 1], { route, optional, title, });
  32. }
  33. return ref;
  34. }
  35. export function getPath(value?: string) {
  36. return Routes[ value as keyof typeof Routes ];
  37. }