index.js 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  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. {
  30. path: '/',
  31. redirect: 'forest',
  32. },
  33. {
  34. //林业中心
  35. path: '/forest',
  36. name: 'forest',
  37. component: () => import('@/views/forest'),
  38. meta: {
  39. title: '林业云图'
  40. }
  41. },
  42. {
  43. //数据中心
  44. path: '/datacenter',
  45. name: 'datacenter',
  46. component: () => import('@/views/datacenter'),
  47. meta: {
  48. title: '数据中心'
  49. }
  50. },
  51. {
  52. //事件中心
  53. path: '/event',
  54. name: 'event',
  55. component: () => import('@/views/event'),
  56. meta: {
  57. title: '事件中心'
  58. }
  59. },
  60. {
  61. //监控中心
  62. path: '/monitor',
  63. name: 'monitor',
  64. component: () => import('@/views/monitor'),
  65. meta: {
  66. title: '监控中心'
  67. }
  68. },{
  69. path: '/',
  70. name: '',
  71. component: () => import('@/views/monitor'),
  72. meta: {
  73. title: '灾后评估'
  74. }
  75. },{
  76. path: '/',
  77. name: '',
  78. component: () => import('@/views/monitor'),
  79. meta: {
  80. title: '动物保护'
  81. }
  82. },{
  83. path: '/',
  84. name: '',
  85. component: () => import('@/views/monitor'),
  86. meta: {
  87. title: '林长制'
  88. }
  89. },{
  90. path: '/',
  91. name: '',
  92. component: () => import('@/views/monitor'),
  93. meta: {
  94. title: '植树造林'
  95. }
  96. },
  97. ]
  98. // 公共路由
  99. export const constantRoutesNew = [
  100. {
  101. path: '/',
  102. redirect: 'forest',
  103. },
  104. {
  105. //林业中心
  106. path: '/forest',
  107. name: 'forest',
  108. component: () => import('@/views/forest'),
  109. meta: {
  110. title: '数字林业'
  111. }
  112. },
  113. {
  114. //数据中心
  115. path: '/datacenter',
  116. name: 'datacenter',
  117. component: () => import('@/views/datacenter'),
  118. meta: {
  119. title: '数据中心'
  120. }
  121. },
  122. {
  123. //事件中心
  124. path: '/event',
  125. name: 'event',
  126. component: () => import('@/views/event'),
  127. meta: {
  128. title: '事件中心'
  129. }
  130. },
  131. {
  132. //监控中心
  133. path: '/monitor',
  134. name: 'monitor',
  135. component: () => import('@/views/monitor'),
  136. meta: {
  137. title: '监控中心'
  138. }
  139. },
  140. {
  141. path: '/login',
  142. component: () => import('@/views/system/login'),
  143. hidden: true
  144. },
  145. {
  146. path: '/register',
  147. component: () => import('@/views/system/register'),
  148. hidden: true
  149. },
  150. {
  151. path: '/404',
  152. component: () => import('@/views/error/404'),
  153. hidden: true
  154. },
  155. {
  156. path: '/401',
  157. component: () => import('@/views/error/401'),
  158. hidden: true
  159. },
  160. {
  161. path: '',
  162. component: Layout,
  163. redirect: 'index',
  164. children: [
  165. {
  166. path: 'forest',
  167. component: () => import('@/views/forest'),
  168. name: 'forest',
  169. meta: { title: '首页', icon: 'dashboard', affix: true }
  170. }
  171. ]
  172. },
  173. {
  174. path: '/user',
  175. component: Layout,
  176. hidden: true,
  177. redirect: 'noredirect',
  178. children: [
  179. {
  180. path: 'profile',
  181. component: () => import('@/views/system/user/profile/index'),
  182. name: 'Profile',
  183. meta: { title: '个人中心', icon: 'user' }
  184. }
  185. ]
  186. },
  187. ]
  188. // 动态路由,基于用户权限动态去加载
  189. export const dynamicRoutes = [
  190. {
  191. path: '/system/user-auth',
  192. component: Layout,
  193. hidden: true,
  194. permissions: ['system:user:edit'],
  195. children: [
  196. {
  197. path: 'role/:userId(\\d+)',
  198. component: () => import('@/views/system/user/authRole'),
  199. name: 'AuthRole',
  200. meta: { title: '分配角色', activeMenu: '/system/user' }
  201. }
  202. ]
  203. },
  204. {
  205. path: '/system/role-auth',
  206. component: Layout,
  207. hidden: true,
  208. permissions: ['system:role:edit'],
  209. children: [
  210. {
  211. path: 'user/:roleId(\\d+)',
  212. component: () => import('@/views/system/role/authUser'),
  213. name: 'AuthUser',
  214. meta: { title: '分配用户', activeMenu: '/system/role' }
  215. }
  216. ]
  217. },
  218. {
  219. path: '/system/dict-data',
  220. component: Layout,
  221. hidden: true,
  222. permissions: ['system:dict:list'],
  223. children: [
  224. {
  225. path: 'index/:dictId(\\d+)',
  226. component: () => import('@/views/system/dict/data'),
  227. name: 'Data',
  228. meta: { title: '字典数据', activeMenu: '/system/dict' }
  229. }
  230. ]
  231. },
  232. ]
  233. // 防止连续点击多次路由报错
  234. let routerPush = Router.prototype.push;
  235. Router.prototype.push = function push(location) {
  236. return routerPush.call(this, location).catch(err => err)
  237. }
  238. export default new Router({
  239. mode: 'history', // 去掉url中的#
  240. scrollBehavior: () => ({ y: 0 }),
  241. routes: constantRoutesNew
  242. })