Newer
Older
DH_Apicture / src / router / index.js
@chenke chenke on 8 Dec 5 KB add
  1. import { createWebHistory, createWebHashHistory, createRouter } from 'vue-router';
  2. /* Layout */
  3. import Layout from '@/layout';
  4.  
  5. /**
  6. * Note: 路由配置项
  7. *
  8. * hidden: true // 当设置 true 的时候该路由不会再侧边栏出现 如401,login等页面,或者如一些编辑页面/edit/1
  9. * alwaysShow: true // 当你一个路由下面的 children 声明的路由大于1个时,自动会变成嵌套的模式--如组件页面
  10. * // 只有一个时,会将那个子路由当做根路由显示在侧边栏--如引导页面
  11. * // 若你想不管路由下面的 children 声明的个数都显示你的根路由
  12. * // 你可以设置 alwaysShow: true,这样它就会忽略之前定义的规则,一直显示根路由
  13. * redirect: noRedirect // 当设置 noRedirect 的时候该路由在面包屑导航中不可被点击
  14. * name:'router-name' // 设定路由的名字,一定要填写不然使用<keep-alive>时会出现各种问题
  15. * query: '{"id": 1, "name": "ry"}' // 访问路由的默认传递参数
  16. * roles: ['admin', 'common'] // 访问路由的角色权限
  17. * permissions: ['a:a:a', 'b:b:b'] // 访问路由的菜单权限
  18. * meta : {
  19. noCache: true // 如果设置为true,则不会被 <keep-alive> 缓存(默认 false)
  20. title: 'title' // 设置该路由在侧边栏和面包屑中展示的名字
  21. icon: 'svg-name' // 设置该路由的图标,对应路径src/assets/icons/svg
  22. breadcrumb: false // 如果设置为false,则不会在breadcrumb面包屑中显示
  23. activeMenu: '/system/user' // 当路由设置了该属性,则会高亮相对应的侧边栏。
  24. }
  25. */
  26.  
  27. // 公共路由
  28. export const constantRoutes = [
  29. {
  30. path: '/',
  31. component: () => import('@/views/pictureOnMap/index.vue'),
  32. hidden: true,
  33. },
  34. {
  35. path: '/redirect',
  36. component: Layout,
  37. hidden: true,
  38. children: [
  39. {
  40. path: '/redirect/:path(.*)',
  41. component: () => import('@/views/redirect/index.vue'),
  42. },
  43. ],
  44. },
  45. {
  46. path: '/login',
  47. component: () => import('@/views/login'),
  48. hidden: true,
  49. },
  50. {
  51. path: '/:pathMatch(.*)*',
  52. component: () => import('@/views/error/404'),
  53. hidden: true,
  54. },
  55. {
  56. path: '/401',
  57. component: () => import('@/views/error/401'),
  58. hidden: true,
  59. },
  60. {
  61. path: '',
  62. name: 'pictureOnMap',
  63. component: () => import('@/views/pictureOnMap/index.vue'),
  64. redirect: '/WaterAssets',
  65. hidden: true,
  66. children: [
  67. {
  68. path: '/WaterAssets',
  69. name: 'WaterAssets',
  70. component: () => import('@/views/pictureOnMap/page/WaterAssets/index.vue'),
  71. },
  72. {
  73. path: '/FloodControlSafety',
  74. name: 'FloodControlSafety',
  75. component: () => import('@/views/pictureOnMap/page/FloodControlSafety/index.vue'),
  76. },
  77. {
  78. path: '/FloodControlAndDrainage',
  79. name: 'FloodControlAndDrainage',
  80. component: () => import('@/views/pictureOnMap/page/FloodControlAndDrainage/index.vue'),
  81. },
  82. {
  83. path: '/MonitoringAnalysis',
  84. name: 'MonitoringAnalysis',
  85. component: () => import('@/views/pictureOnMap/page/MonitoringAnalysis/index.vue'),
  86. },
  87. {
  88. path: '/RiverAndLakeEcology',
  89. name: 'RiverAndLakeEcology',
  90. component: () => import('@/views/pictureOnMap/page/RiverAndLakeEcology/index.vue'),
  91. },
  92. {
  93. path: '/PublicOpinionAnalysis',
  94. name: 'PublicOpinionAnalysis',
  95. component: () => import('@/views/pictureOnMap/page/PublicOpinionAnalysis/index.vue'),
  96. },
  97. {
  98. path: '/DrainageSystem',
  99. name: 'DrainageSystem',
  100. component: () => import('@/views/pictureOnMap/page/DrainageSystem/index.vue'),
  101. },
  102. ],
  103. },
  104. // {
  105. // path: '/index2',
  106. // name:'排涝调度',
  107. // component: () => import('@/views/pictureOnMap/index2.vue'),
  108. // },
  109. // {
  110. // path: '/index3',
  111. // name:'排涝调度3',
  112. // component: () => import('@/views/pictureOnMap/index3.vue'),
  113. // },
  114.  
  115. // {
  116. // path: '',
  117. // component: Layout,
  118. // redirect: '/index',
  119. // children: [
  120. // {
  121. // path: '/index',
  122. // component: () => import('@/views/index'),
  123. // name: 'Index',
  124. // meta: { title: '首页', icon: 'dashboard', affix: true, noCache: true },
  125. // },
  126. // ],
  127. // },
  128. {
  129. path: '/user',
  130. component: Layout,
  131. hidden: true,
  132. redirect: 'noredirect',
  133. children: [
  134. {
  135. path: 'profile',
  136. component: () => import('@/views/system/user/profile/index'),
  137. name: 'Profile',
  138. meta: { title: '个人中心', icon: 'user' },
  139. },
  140. ],
  141. },
  142. ];
  143.  
  144. // 动态路由,基于用户权限动态去加载
  145. export const dynamicRoutes = [];
  146.  
  147. const router = createRouter({
  148. // history: createWebHistory(),
  149. history: createWebHashHistory('/WaterBrain/'),
  150. routes: constantRoutes,
  151. scrollBehavior(to, from, savedPosition) {
  152. if (savedPosition) {
  153. return savedPosition;
  154. } else {
  155. return { top: 0 };
  156. }
  157. },
  158. });
  159.  
  160. export default router;