index.ts 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. import { createRouter, createWebHistory } from 'vue-router'
  2. import { defineAsyncComponent } from 'vue'
  3. // import Home from '@/views/Home.vue'
  4. // import HomeView from '@/views/HomeView.vue'
  5. //路由异步加载
  6. //主页框架
  7. const Home = () => import('@/views/Home.vue')
  8. //首页详细内容
  9. const HomeView = () => import('@/views/HomeView.vue')
  10. //科普内容
  11. const PopularizationScience = () => import('@/views/PopularizationScience.vue')
  12. const Community = () => import('@/views/Community.vue')
  13. // 组件异步懒加载方法
  14. // const _import = (path: string) =>
  15. // defineAsyncComponent(() => import(`../views/${path}.vue`))
  16. const routes = [
  17. {
  18. path: '/',
  19. name: 'home',
  20. // component: Home,
  21. component: Home,
  22. redirect: "/homeView",
  23. children: [{
  24. path: 'homeView',
  25. name: 'homeView',
  26. component: HomeView
  27. // component: _import('HomeView')
  28. },
  29. {
  30. path: 'popularizationScience',
  31. name: 'popularizationScience',
  32. component: PopularizationScience
  33. },
  34. {
  35. path: 'community',
  36. name: 'community',
  37. component: () => import('@/views/Community.vue')
  38. }, {
  39. path: 'plan',
  40. name: 'plan',
  41. component: () => import('@/views/Plan.vue')
  42. }, {
  43. path: 'testRecord',
  44. name: 'testRecord',
  45. component: () => import('@/views/TestRecord.vue')
  46. }, {
  47. path: 'report/:id',
  48. name: 'report',
  49. component: () => import('@/views/Report.vue')
  50. },
  51. {
  52. path: 'login',
  53. name: 'login',
  54. component: () => import('@/views/Login.vue')
  55. },
  56. {
  57. path: 'register',
  58. name: 'register',
  59. component: () => import('@/views/Register.vue')
  60. },
  61. {
  62. path: 'scale/:planId/:planName/:flag/:flagName/:num',
  63. name: 'scale',
  64. component: () => import('@/views/Scale.vue')
  65. },
  66. {
  67. path: 'scaleMid',
  68. name: 'scaleMid',
  69. component: () => import('@/views/ScaleMid.vue')//量表中间件
  70. },
  71. //认知任务
  72. {
  73. path: 'cognize/:planId/:planName/:flag/:flagName/:num',
  74. name: 'cognize',
  75. component: () => import('@/views/Cognize.vue')
  76. }
  77. ]
  78. // component: HomeView
  79. },
  80. {
  81. path: '/cognizeGoNoGo/:currentType/:planId/:planName/:flag/:flagName/:num',
  82. name: 'cognizeGoNoGo',
  83. component: () => import('@/views/CognizeGoNoGo.vue')
  84. }, {
  85. path: '/cognizeFaceDot/:currentType/:planId/:planName/:flag/:flagName/:num',
  86. name: 'cognizeFaceDot',
  87. component: () => import('@/views/CognizeFaceDot.vue')
  88. }
  89. ]
  90. const router = createRouter({
  91. history: createWebHistory(import.meta.env.BASE_URL),
  92. routes
  93. })
  94. export default router