index.js 7.8 KB

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