index.js 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  1. import Vue from 'vue'
  2. import Router from 'vue-router'
  3. Vue.use(Router)
  4. /* Layout */
  5. import Layout from '@/layout'
  6. /**
  7. * Note: 路由配置项
  8. *
  9. * hidden: true // 当设置 true 的时候该路由不会再侧边栏出现 如401,login等页面,或者如一些编辑页面/edit/1
  10. * alwaysShow: true // 当你一个路由下面的 children 声明的路由大于1个时,自动会变成嵌套的模式--如组件页面
  11. * // 只有一个时,会将那个子路由当做根路由显示在侧边栏--如引导页面
  12. * // 若你想不管路由下面的 children 声明的个数都显示你的根路由
  13. * // 你可以设置 alwaysShow: true,这样它就会忽略之前定义的规则,一直显示根路由
  14. * redirect: noRedirect // 当设置 noRedirect 的时候该路由在面包屑导航中不可被点击
  15. * name:'router-name' // 设定路由的名字,一定要填写不然使用<keep-alive>时会出现各种问题
  16. * query: '{"id": 1, "name": "ry"}' // 访问路由的默认传递参数
  17. * roles: ['admin', 'common'] // 访问路由的角色权限
  18. * permissions: ['a:a:a', 'b:b:b'] // 访问路由的菜单权限
  19. * meta : {
  20. noCache: true // 如果设置为true,则不会被 <keep-alive> 缓存(默认 false)
  21. title: 'title' // 设置该路由在侧边栏和面包屑中展示的名字
  22. icon: 'svg-name' // 设置该路由的图标,对应路径src/assets/icons/svg
  23. breadcrumb: false // 如果设置为false,则不会在breadcrumb面包屑中显示
  24. activeMenu: '/system/user' // 当路由设置了该属性,则会高亮相对应的侧边栏。
  25. }
  26. */
  27. // 公共路由(可视化首页头部链接)
  28. export const constantRoutes = [{
  29. path: '/',
  30. redirect: 'forest',
  31. },
  32. {
  33. //交通云图
  34. path: '/forest',
  35. name: 'forest',
  36. component: () => import('@/views/forest'),
  37. meta: {
  38. title: '交通云图'
  39. }
  40. },
  41. {
  42. //监控中心
  43. path: '/monitor',
  44. name: 'monitor',
  45. component: () => import('@/views/monitor'),
  46. meta: {
  47. title: '监控中心'
  48. }
  49. },
  50. {
  51. //交通人员
  52. path: '/leader',
  53. name: 'leader',
  54. component: () => import('@/views/leader'),
  55. meta: {
  56. title: '路长制'
  57. }
  58. },
  59. {
  60. //交通资源
  61. path: '/resources',
  62. name: 'resources',
  63. component: () => import('@/views/resources'),
  64. meta: {
  65. title: '交通资源'
  66. }
  67. },
  68. {
  69. path: '/bigdata',
  70. name: 'bigdata',
  71. component: () => import('@/views/bigdata/bigdata'),
  72. meta: {
  73. title: '统计分析'
  74. }
  75. },
  76. ]
  77. // 公共路由
  78. export const constantRoutesNew = [{
  79. path: '/',
  80. redirect: 'forest',
  81. },
  82. {
  83. //林业中心
  84. path: '/forest',
  85. name: 'forest',
  86. component: () => import('@/views/forest'),
  87. meta: {
  88. title: '交通云图'
  89. }
  90. },
  91. {
  92. //监控中心
  93. path: '/monitor',
  94. name: 'monitor',
  95. component: () => import('@/views/monitor'),
  96. meta: {
  97. title: '监控中心'
  98. }
  99. },
  100. {
  101. //交通人员
  102. path: '/leader',
  103. name: 'leader',
  104. component: () => import('@/views/leader'),
  105. meta: {
  106. title: '路长制'
  107. }
  108. },
  109. {
  110. //交通资源
  111. path: '/resources',
  112. name: 'resources',
  113. component: () => import('@/views/resources'),
  114. meta: {
  115. title: '交通资源'
  116. }
  117. },
  118. {
  119. path: '/bigdata',
  120. name: 'bigdata',
  121. component: () => import('@/views/bigdata/bigdata'),
  122. meta: {
  123. title: '统计分析'
  124. }
  125. },
  126. {
  127. path: '/login',
  128. component: () => import('@/views/system/login'),
  129. hidden: true
  130. },
  131. {
  132. path: '/register',
  133. component: () => import('@/views/system/register'),
  134. hidden: true
  135. },
  136. {
  137. path: '/404',
  138. component: () => import('@/views/error/404'),
  139. hidden: true
  140. },
  141. {
  142. path: '/401',
  143. component: () => import('@/views/error/401'),
  144. hidden: true
  145. },
  146. {
  147. path: '',
  148. component: Layout,
  149. redirect: 'index',
  150. children: [{
  151. path: 'forest',
  152. component: () => import('@/views/forest'),
  153. name: 'forest',
  154. meta: {
  155. title: '首页',
  156. icon: 'dashboard',
  157. affix: true
  158. }
  159. }]
  160. },
  161. {
  162. path: '/user',
  163. component: Layout,
  164. hidden: true,
  165. redirect: 'noredirect',
  166. children: [{
  167. path: 'profile',
  168. component: () => import('@/views/system/user/profile/index'),
  169. name: 'Profile',
  170. meta: {
  171. title: '个人中心',
  172. icon: 'user'
  173. }
  174. }]
  175. },
  176. ]
  177. // 动态路由,基于用户权限动态去加载
  178. export const dynamicRoutes = [{
  179. path: '/system/user-auth',
  180. component: Layout,
  181. hidden: true,
  182. permissions: ['system:user:edit'],
  183. children: [{
  184. path: 'role/:userId(\\d+)',
  185. component: () => import('@/views/system/user/authRole'),
  186. name: 'AuthRole',
  187. meta: {
  188. title: '分配角色',
  189. activeMenu: '/system/user'
  190. }
  191. }]
  192. },
  193. {
  194. path: '/system/role-auth',
  195. component: Layout,
  196. hidden: true,
  197. permissions: ['system:role:edit'],
  198. children: [{
  199. path: 'user/:roleId(\\d+)',
  200. component: () => import('@/views/system/role/authUser'),
  201. name: 'AuthUser',
  202. meta: {
  203. title: '分配用户',
  204. activeMenu: '/system/role'
  205. }
  206. }]
  207. },
  208. {
  209. path: '/system/dict-data',
  210. component: Layout,
  211. hidden: true,
  212. permissions: ['system:dict:list'],
  213. children: [{
  214. path: 'index/:dictId(\\d+)',
  215. component: () => import('@/views/system/dict/data'),
  216. name: 'Data',
  217. meta: {
  218. title: '字典数据',
  219. activeMenu: '/system/dict'
  220. }
  221. }]
  222. },
  223. ]
  224. // 防止连续点击多次路由报错
  225. let routerPush = Router.prototype.push;
  226. Router.prototype.push = function push(location) {
  227. return routerPush.call(this, location).catch(err => err)
  228. }
  229. export default new Router({
  230. mode: 'history', // 去掉url中的#
  231. scrollBehavior: () => ({
  232. y: 0
  233. }),
  234. routes: constantRoutesNew
  235. })