index.js 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300
  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: '/datacenter',
  44. name: 'datacenter',
  45. component: () => import('@/views/datacenter'),
  46. meta: {
  47. title: '数据中心'
  48. }
  49. },
  50. {
  51. //监控中心
  52. path: '/monitor',
  53. name: 'monitor',
  54. component: () => import('@/views/monitor'),
  55. meta: {
  56. title: '监控中心'
  57. }
  58. },
  59. {
  60. path: '/bigdata',
  61. name: 'bigdata',
  62. component: () => import('@/views/bigdata/bigdata'),
  63. meta: {
  64. title: '统计分析'
  65. }
  66. },
  67. // {
  68. // path: '/leader',
  69. // name: 'leader',
  70. // component: () => import('@/views/leader'),
  71. // meta: {
  72. // title: '林长制'
  73. // }
  74. // }, {
  75. // path: '/afforestation',
  76. // name: 'afforestation',
  77. // component: () => import('@/views/afforestation'),
  78. // meta: {
  79. // title: '植树造林'
  80. // }
  81. // },
  82. // {
  83. // path: '/',
  84. // name: '',
  85. // component: () => import('@/views/animal'),
  86. // meta: {
  87. // title: '动物保护'
  88. // }
  89. // },
  90. // {
  91. // path: '/',
  92. // name: '',
  93. // component: () => import('@/views/animal'),
  94. // meta: {
  95. // title: '珍惜古树'
  96. // }
  97. // },
  98. ]
  99. // 公共路由
  100. export const constantRoutesNew = [{
  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: '/monitor',
  125. name: 'monitor',
  126. component: () => import('@/views/monitor'),
  127. meta: {
  128. title: '监控中心'
  129. }
  130. },
  131. {
  132. path: '/bigdata',
  133. name: 'bigdata',
  134. component: () => import('@/views/bigdata/bigdata'),
  135. meta: {
  136. title: '统计分析'
  137. }
  138. },
  139. // {
  140. // path: '/disaster',
  141. // name: 'disaster',
  142. // component: () => import('@/views/disaster'),
  143. // meta: {
  144. // title: '灾后评估'
  145. // }
  146. // },
  147. // {
  148. // path: '/leader',
  149. // name: 'leader',
  150. // component: () => import('@/views/leader'),
  151. // meta: {
  152. // title: '林长制'
  153. // }
  154. // },
  155. // {
  156. // path: '/afforestation',
  157. // name: 'afforestation',
  158. // component: () => import('@/views/afforestation'),
  159. // meta: {
  160. // title: '植树造林'
  161. // }
  162. // },
  163. // {
  164. // path: '/',
  165. // name: '',
  166. // component: () => import('@/views/animal'),
  167. // meta: {
  168. // title: '动物保护'
  169. // }
  170. // },
  171. // {
  172. // path: '/',
  173. // name: '',
  174. // component: () => import('@/views/animal'),
  175. // meta: {
  176. // title: '珍惜古树'
  177. // }
  178. // },
  179. {
  180. path: '/login',
  181. component: () => import('@/views/system/login'),
  182. hidden: true
  183. },
  184. {
  185. path: '/register',
  186. component: () => import('@/views/system/register'),
  187. hidden: true
  188. },
  189. {
  190. path: '/404',
  191. component: () => import('@/views/error/404'),
  192. hidden: true
  193. },
  194. {
  195. path: '/401',
  196. component: () => import('@/views/error/401'),
  197. hidden: true
  198. },
  199. {
  200. path: '',
  201. component: Layout,
  202. redirect: 'index',
  203. children: [{
  204. path: 'forest',
  205. component: () => import('@/views/forest'),
  206. name: 'forest',
  207. meta: {
  208. title: '首页',
  209. icon: 'dashboard',
  210. affix: true
  211. }
  212. }]
  213. },
  214. {
  215. path: '/user',
  216. component: Layout,
  217. hidden: true,
  218. redirect: 'noredirect',
  219. children: [{
  220. path: 'profile',
  221. component: () => import('@/views/system/user/profile/index'),
  222. name: 'Profile',
  223. meta: {
  224. title: '个人中心',
  225. icon: 'user'
  226. }
  227. }]
  228. },
  229. ]
  230. // 动态路由,基于用户权限动态去加载
  231. export const dynamicRoutes = [{
  232. path: '/system/user-auth',
  233. component: Layout,
  234. hidden: true,
  235. permissions: ['system:user:edit'],
  236. children: [{
  237. path: 'role/:userId(\\d+)',
  238. component: () => import('@/views/system/user/authRole'),
  239. name: 'AuthRole',
  240. meta: {
  241. title: '分配角色',
  242. activeMenu: '/system/user'
  243. }
  244. }]
  245. },
  246. {
  247. path: '/system/role-auth',
  248. component: Layout,
  249. hidden: true,
  250. permissions: ['system:role:edit'],
  251. children: [{
  252. path: 'user/:roleId(\\d+)',
  253. component: () => import('@/views/system/role/authUser'),
  254. name: 'AuthUser',
  255. meta: {
  256. title: '分配用户',
  257. activeMenu: '/system/role'
  258. }
  259. }]
  260. },
  261. {
  262. path: '/system/dict-data',
  263. component: Layout,
  264. hidden: true,
  265. permissions: ['system:dict:list'],
  266. children: [{
  267. path: 'index/:dictId(\\d+)',
  268. component: () => import('@/views/system/dict/data'),
  269. name: 'Data',
  270. meta: {
  271. title: '字典数据',
  272. activeMenu: '/system/dict'
  273. }
  274. }]
  275. },
  276. ]
  277. // 防止连续点击多次路由报错
  278. let routerPush = Router.prototype.push;
  279. Router.prototype.push = function push(location) {
  280. return routerPush.call(this, location).catch(err => err)
  281. }
  282. export default new Router({
  283. mode: 'history', // 去掉url中的#
  284. scrollBehavior: () => ({
  285. y: 0
  286. }),
  287. routes: constantRoutesNew
  288. })