index.ts 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. import { createRouter, createWebHistory } from 'vue-router';
  2. import { accountGuard } from '@/router/guard/account.guard';
  3. const router = createRouter({
  4. history: createWebHistory(import.meta.env.BASE_URL),
  5. routes: [
  6. { path: '/login', name: 'login', component: () => import('@/pages/login.vue') },
  7. { path: '/screen', name: 'screen', component: () => import('@/pages/screen.page.vue'), meta: { scan: true } },
  8. { path: '/register', component: () => import('@/pages/register.page.vue'), meta: { title: '建档', scan: true } },
  9. { path: '/pulse', component: () => import('@/modules/pulse/pulse.page.vue'), meta: { title: '脉诊' } },
  10. { path: '/pulse/result', component: () => import('@/modules/pulse/pulse-result.page.vue'), meta: { title: '脉象分析报告' } },
  11. { path: '/camera', component: () => import('@/modules/camera/camera.page.vue'), meta: { title: '拍摄' } },
  12. { path: '/camera/result', component: () => import('@/modules/report/report-analyse.page.vue'), meta: { title: '舌面象分析报告' } },
  13. { path: '/questionnaire', component: () => import('@/modules/questionnaire/page.vue'), meta: { title: '问卷' } },
  14. { path: '/alcohol/result', component: () => import('@/modules/alcohol/alcohol.page.vue'), meta: { title: '黄酒建议' } },
  15. { path: '/report/analysis', redirect: '/camera/result' },
  16. { path: '/report/:id/scheme', component: () => import('@/modules/report/scheme.page.vue'), meta: { title: '调理方案', toggle: true } },
  17. { path: '/report/:id(\\w+)?', component: () => import('@/modules/report/report.page.vue'), meta: { title: '健康分析报告' } },
  18. { path: '/scheme/:id(\\w+)?', component: () => import('@/modules/report/scheme.page.vue'), meta: { title: '调理方案', toggle: false } },
  19. { path: '/crossing/:flow(\\w+)?', component: () => import('@/pages/crossing.page.vue') },
  20. {
  21. path: '/manage',
  22. children: [
  23. { path: 'system/role', component: () => import('@/modules/system/role.page.vue'), meta: { title: '角色管理' } },
  24. { path: 'system/user', component: () => import('@/modules/system/user.page.vue'), meta: { title: '用户管理' } },
  25. { path: 'system/logger', component: () => import('@/modules/system/logger.page.vue'), meta: { title: '日志管理' } },
  26. ],
  27. },
  28. { path: '/forbidden', name: 'forbidden', component: () => import('@/router/pages/forbidden.page.vue') },
  29. { path: '/', redirect: '/screen' },
  30. ],
  31. });
  32. router.beforeEach(accountGuard);
  33. export default router;
  34. export const flow_start = 'start';
  35. export const flow_router = {
  36. 'patient_file': '/register',
  37. 'pulse_upload': '/pulse',
  38. 'pulse_upload_result': '/pulse/result',
  39. 'tongueface_upload': '/camera',
  40. 'tongueface_analysis_result': '/camera/result',
  41. 'tongueface_analysis': '/questionnaire',
  42. 'alcohol_upload_result': '/alcohol/result',
  43. 'health_analysis': '/report',
  44. 'health_analysis_scheme': '/scheme',
  45. [flow_start]: '/screen',
  46. } as const;
  47. export function getRoutePath(key?: string) {
  48. key = key?.split('?')?.[0];
  49. return flow_router[key as keyof typeof flow_router];
  50. }