index.ts 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. import { createRouter, createWebHistory, RouteRecordRaw } from "vue-router";
  2. export const Layout = () => import("@/layout/index.vue");
  3. // 静态路由
  4. export const constantRoutes: RouteRecordRaw[] = [
  5. // {
  6. // path: "/redirect",
  7. // component: Layout,
  8. // meta: { hidden: true },
  9. // children: [
  10. // {
  11. // path: "/redirect/:path(.*)",
  12. // component: () => import("@/views/redirect/index.vue"),
  13. // },
  14. // ],
  15. // },
  16. {
  17. path: "/",
  18. redirect: "/main/home",
  19. meta: { hidden: true },
  20. },
  21. {
  22. path: "/main",
  23. component: () => import("@/views/main/main.vue"),
  24. meta: { hidden: true },
  25. redirect: "/main/home",
  26. children: [
  27. {
  28. path: "home",
  29. component: () => import("@/views/modules/home/home.vue"),
  30. },
  31. {
  32. path: "run-test/:engineerId",
  33. name: "RunTestPage",
  34. component: () => import("@/views/modules/runTest/run-test.vue"),
  35. },
  36. {
  37. path: "data-manager",
  38. component: () =>
  39. import("@/views/modules/data-manager/data-manager.vue"),
  40. },
  41. {
  42. path: "project-config/:engineerId",
  43. name: "ProjectConfig",
  44. component: () =>
  45. import("@/views/modules/project-config/project-config.vue"),
  46. },
  47. {
  48. path: "report-template",
  49. component: () =>
  50. import("@/views/modules/report-template/report-template.vue"),
  51. },
  52. {
  53. path: "person-manager",
  54. component: () =>
  55. import("@/views/modules/person-manager/person-manager.vue"),
  56. },
  57. ],
  58. },
  59. {
  60. path: "/global-config/:engineerId",
  61. name: "GlobalConfig",
  62. component: () => import("@/views/modules/global-config/global-config.vue"),
  63. meta: { hidden: true },
  64. },
  65. // {
  66. // path: "/test",
  67. // component: () => import("@/views/modules/home/test/test.vue"),
  68. // meta: { hidden: true },
  69. // redirect: "/main/home",
  70. // children: [
  71. // {
  72. // path: "test1",
  73. // component: () => import("@/views/modules/home/home.vue"),
  74. // },
  75. // ],
  76. // },
  77. {
  78. path: "/login",
  79. component: () => import("@/views/demo/test-dark.vue"),
  80. meta: { hidden: true },
  81. },
  82. // {
  83. // path: "/",
  84. // name: "/",
  85. // component: Layout,
  86. // redirect: "/dashboard",
  87. // children: [
  88. // {
  89. // path: "dashboard",
  90. // component: () => import("@/views/dashboard/index.vue"),
  91. // name: "Dashboard", // 用于 keep-alive, 必须与SFC自动推导或者显示声明的组件name一致
  92. // // https://cn.vuejs.org/guide/built-ins/keep-alive.html#include-exclude
  93. // meta: {
  94. // title: "dashboard",
  95. // icon: "homepage",
  96. // affix: true,
  97. // keepAlive: true,
  98. // alwaysShow: false,
  99. // },
  100. // },
  101. // {
  102. // path: "401",
  103. // component: () => import("@/views/error-page/401.vue"),
  104. // meta: { hidden: true },
  105. // },
  106. // {
  107. // path: "404",
  108. // component: () => import("@/views/error-page/404.vue"),
  109. // meta: { hidden: true },
  110. // },
  111. // ],
  112. // },
  113. {
  114. path: "/:pathMatch(.*)*", // 必备
  115. component: () => import("@/views/error-page/404.vue"),
  116. },
  117. // 外部链接
  118. // {
  119. // path: "/external-link",
  120. // component: Layout,
  121. // children: [ {
  122. // component: () => import("@/views/external-link/index.vue"),
  123. // path: "https://www.cnblogs.com/haoxianrui/",
  124. // meta: { title: "外部链接", icon: "link" },
  125. // },
  126. // ],
  127. // },
  128. // 多级嵌套路由
  129. /* {
  130. path: '/nested',
  131. component: Layout,
  132. redirect: '/nested/level1/level2',
  133. name: 'Nested',
  134. meta: {title: '多级菜单', icon: 'nested'},
  135. children: [
  136. {
  137. path: 'level1',
  138. component: () => import('@/views/nested/level1/index.vue'),
  139. name: 'Level1',
  140. meta: {title: '菜单一级'},
  141. redirect: '/nested/level1/level2',
  142. children: [
  143. {
  144. path: 'level2',
  145. component: () => import('@/views/nested/level1/level2/index.vue'),
  146. name: 'Level2',
  147. meta: {title: '菜单二级'},
  148. redirect: '/nested/level1/level2/level3',
  149. children: [
  150. {
  151. path: 'level3-1',
  152. component: () => import('@/views/nested/level1/level2/level3/index1.vue'),
  153. name: 'Level3-1',
  154. meta: {title: '菜单三级-1'}
  155. },
  156. {
  157. path: 'level3-2',
  158. component: () => import('@/views/nested/level1/level2/level3/index2.vue'),
  159. name: 'Level3-2',
  160. meta: {title: '菜单三级-2'}
  161. }
  162. ]
  163. }
  164. ]
  165. },
  166. ]
  167. }*/
  168. ];
  169. /**
  170. * 创建路由
  171. */
  172. const router = createRouter({
  173. history: createWebHistory(),
  174. routes: constantRoutes,
  175. // 刷新时,滚动条位置还原
  176. scrollBehavior: () => ({ left: 0, top: 0 }),
  177. });
  178. /**
  179. * 重置路由
  180. */
  181. export function resetRouter() {
  182. router.replace({ path: "/login" });
  183. }
  184. export default router;