index.js 7.0 KB

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