index.ts 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  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: "/deviceResources",
  67. component: () =>
  68. import("@/views/modules/global-config/deviceResources.vue"),
  69. meta: { hidden: true },
  70. },
  71. // {
  72. // path: "/test",
  73. // component: () => import("@/views/modules/home/test/test.vue"),
  74. // meta: { hidden: true },
  75. // redirect: "/main/home",
  76. // children: [
  77. // {
  78. // path: "test1",
  79. // component: () => import("@/views/modules/home/home.vue"),
  80. // },
  81. // ],
  82. // },
  83. {
  84. path: "/login",
  85. component: () => import("@/views/demo/test-dark.vue"),
  86. meta: { hidden: true },
  87. },
  88. // {
  89. // path: "/",
  90. // name: "/",
  91. // component: Layout,
  92. // redirect: "/dashboard",
  93. // children: [
  94. // {
  95. // path: "dashboard",
  96. // component: () => import("@/views/dashboard/index.vue"),
  97. // name: "Dashboard", // 用于 keep-alive, 必须与SFC自动推导或者显示声明的组件name一致
  98. // // https://cn.vuejs.org/guide/built-ins/keep-alive.html#include-exclude
  99. // meta: {
  100. // title: "dashboard",
  101. // icon: "homepage",
  102. // affix: true,
  103. // keepAlive: true,
  104. // alwaysShow: false,
  105. // },
  106. // },
  107. // {
  108. // path: "401",
  109. // component: () => import("@/views/error-page/401.vue"),
  110. // meta: { hidden: true },
  111. // },
  112. // {
  113. // path: "404",
  114. // component: () => import("@/views/error-page/404.vue"),
  115. // meta: { hidden: true },
  116. // },
  117. // ],
  118. // },
  119. {
  120. path: "/:pathMatch(.*)*", // 必备
  121. component: () => import("@/views/error-page/404.vue"),
  122. },
  123. // 外部链接
  124. // {
  125. // path: "/external-link",
  126. // component: Layout,
  127. // children: [ {
  128. // component: () => import("@/views/external-link/index.vue"),
  129. // path: "https://www.cnblogs.com/haoxianrui/",
  130. // meta: { title: "外部链接", icon: "link" },
  131. // },
  132. // ],
  133. // },
  134. // 多级嵌套路由
  135. /* {
  136. path: '/nested',
  137. component: Layout,
  138. redirect: '/nested/level1/level2',
  139. name: 'Nested',
  140. meta: {title: '多级菜单', icon: 'nested'},
  141. children: [
  142. {
  143. path: 'level1',
  144. component: () => import('@/views/nested/level1/index.vue'),
  145. name: 'Level1',
  146. meta: {title: '菜单一级'},
  147. redirect: '/nested/level1/level2',
  148. children: [
  149. {
  150. path: 'level2',
  151. component: () => import('@/views/nested/level1/level2/index.vue'),
  152. name: 'Level2',
  153. meta: {title: '菜单二级'},
  154. redirect: '/nested/level1/level2/level3',
  155. children: [
  156. {
  157. path: 'level3-1',
  158. component: () => import('@/views/nested/level1/level2/level3/index1.vue'),
  159. name: 'Level3-1',
  160. meta: {title: '菜单三级-1'}
  161. },
  162. {
  163. path: 'level3-2',
  164. component: () => import('@/views/nested/level1/level2/level3/index2.vue'),
  165. name: 'Level3-2',
  166. meta: {title: '菜单三级-2'}
  167. }
  168. ]
  169. }
  170. ]
  171. },
  172. ]
  173. }*/
  174. ];
  175. /**
  176. * 创建路由
  177. */
  178. const router = createRouter({
  179. history: createWebHistory(),
  180. routes: constantRoutes,
  181. // 刷新时,滚动条位置还原
  182. scrollBehavior: () => ({ left: 0, top: 0 }),
  183. });
  184. /**
  185. * 重置路由
  186. */
  187. export function resetRouter() {
  188. router.replace({ path: "/login" });
  189. }
  190. export default router;