index.js 6.9 KB

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