index.js 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  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: sub-menu only appear when route children.length >= 1
  8. * Detail see: https://panjiachen.github.io/vue-element-admin-site/guide/essentials/router-and-nav.html
  9. *
  10. * hidden: true if set true, item will not show in the sidebar(default is false)
  11. * alwaysShow: true if set true, will always show the root menu
  12. * if not set alwaysShow, when item has more than one children route,
  13. * it will becomes nested mode, otherwise not show the root menu
  14. * redirect: noRedirect if set noRedirect will no redirect in the breadcrumb
  15. * name:'router-name' the name is used by <keep-alive> (must set!!!)
  16. * meta : {
  17. roles: ['admin','editor'] control the page roles (you can set multiple roles)
  18. title: 'title' the name show in sidebar and breadcrumb (recommend set)
  19. icon: 'svg-name'/'el-icon-x' the icon show in the sidebar
  20. breadcrumb: false if set false, the item will hidden in breadcrumb(default is true)
  21. activeMenu: '/example/list' if set path, the sidebar will highlight the path you set
  22. }
  23. */
  24. /**
  25. * constantRoutes
  26. * a base page that does not have permission requirements
  27. * all roles can be accessed
  28. */
  29. export const constantRoutes = [
  30. {
  31. path: '/redirect',
  32. component: Layout,
  33. hidden: true,
  34. children: [
  35. {
  36. path: '/redirect/:path(.*)',
  37. component: () => import('@/views/redirect/index')
  38. }
  39. ]
  40. },
  41. {
  42. path: '/login',
  43. component: () => import('@/views/login/index'),
  44. hidden: true
  45. },
  46. {
  47. path: '/',
  48. component: Layout,
  49. redirect: '/index',
  50. children: [{
  51. path: 'index',
  52. name: 'index',
  53. component: () => import('@/views/dashboard/index'),
  54. meta: { title: '首页', icon: 'dashboard' }
  55. }]
  56. },
  57. {
  58. path: '/catenary',
  59. component: Layout,
  60. redirect: '/catenary/fault',
  61. name: 'catenary',
  62. meta: {
  63. title: '接触网管理',
  64. icon: 'el-icon-film'
  65. },
  66. children: [
  67. {
  68. path: 'fault',
  69. component: () => import('@/views/catenary/fault/index'), // Parent router-view
  70. name: 'fault',
  71. meta: { title: '故障数据管理', icon: 'el-icon-collection-tag' }
  72. },
  73. {
  74. path: 'checklist',
  75. component: () => import('@/views/catenary/checklist/index'),
  76. name: 'checklist',
  77. meta: { title: '检查表管理', icon: 'el-icon-collection-tag' }
  78. },
  79. {
  80. path: 'record',
  81. component: () => import('@/views/catenary/record/index'),
  82. name: 'record',
  83. meta: { title: '检测记录管理', icon: 'el-icon-collection-tag' }
  84. },
  85. {
  86. path: 'stand',
  87. component: () => import('@/views/catenary/stand/index'),
  88. name: 'stand',
  89. meta: { title: '九防台账数据管理', icon: 'el-icon-collection-tag' }
  90. }
  91. ]
  92. },
  93. {
  94. path: '/basics',
  95. component: Layout,
  96. redirect: '/basics/pillar',
  97. name: 'basics',
  98. meta: {
  99. title: '基础数据管理',
  100. icon: 'el-icon-document'
  101. },
  102. children: [
  103. {
  104. path: 'line',
  105. component: () => import('@/views/basics/line/index'), // Parent router-view
  106. name: 'line',
  107. meta: { title: '线路数据', icon: 'el-icon-collection-tag' }
  108. },
  109. {
  110. path: 'section',
  111. component: () => import('@/views/basics/section/index'), // Parent router-view
  112. name: 'section',
  113. meta: { title: '区间站场数据', icon: 'el-icon-collection-tag' }
  114. },
  115. {
  116. path: 'pillar',
  117. component: () => import('@/views/basics/pillar/index'), // Parent router-view
  118. name: 'pillar',
  119. meta: { title: '支柱数据', icon: 'el-icon-collection-tag' }
  120. },
  121. {
  122. path: 'suoting',
  123. component: () => import('@/views/basics/suoting/index'), // Parent router-view
  124. name: 'suoting',
  125. meta: { title: '所亭数据', icon: 'el-icon-collection-tag' }
  126. },
  127. {
  128. path: 'tunnel',
  129. component: () => import('@/views/basics/tunnel/index'), // Parent router-view
  130. name: 'tunnel',
  131. meta: { title: '隧道数据', icon: 'el-icon-collection-tag' }
  132. },
  133. {
  134. path: 'add',
  135. component: () => import('@/views/basics/add/index'), // Parent router-view
  136. name: 'add',
  137. meta: { title: '附加悬挂锚段数据', icon: 'el-icon-collection-tag' }
  138. },
  139. {
  140. path: 'check',
  141. component: () => import('@/views/basics/check/index'), // Parent router-view
  142. name: 'check',
  143. meta: { title: '检查表数据', icon: 'el-icon-collection-tag' }
  144. }
  145. ]
  146. },
  147. // {
  148. // path: 'external-link',
  149. // component: Layout,
  150. // children: [
  151. // {
  152. // path: 'https://baidu.com',
  153. // meta: { title: '外链', icon: 'link' }
  154. // }
  155. // ]
  156. // },
  157. // 404 page must be placed at the end !!!
  158. {
  159. path: '/404',
  160. component: () => import('@/views/404'),
  161. hidden: true
  162. }
  163. ]
  164. export const asyncRoutes = [
  165. {
  166. path: '/sys',
  167. component: Layout,
  168. redirect: '/sys/dept',
  169. name: 'sys',
  170. meta: {
  171. title: '系统管理',
  172. // pages: ['pc:sys'],
  173. icon: 'el-icon-setting'
  174. },
  175. children: [
  176. {
  177. path: 'dept',
  178. component: () => import('@/views/sys/dept/index'), // Parent router-view
  179. name: 'dept',
  180. meta: { title: '部门数据', pages: ['pc:system:dept:list'], icon: 'el-icon-collection-tag' }
  181. },
  182. {
  183. path: 'role',
  184. component: () => import('@/views/sys/role/index'), // Parent router-view
  185. name: 'role',
  186. meta: { title: '职务管理', pages: ['pc:system:role:list'], icon: 'el-icon-collection-tag' }
  187. },
  188. {
  189. path: 'user',
  190. component: () => import('@/views/sys/user/index'), // Parent router-view
  191. name: 'user',
  192. meta: { title: '职工管理', pages: ['pc:system:user:list'], icon: 'el-icon-collection-tag' }
  193. },
  194. {
  195. path: 'dict',
  196. component: () => import('@/views/sys/dict/index'), // Parent router-view
  197. name: 'dict',
  198. meta: { title: '字典管理', pages: ['pc:system:dict:list'], icon: 'el-icon-collection-tag' }
  199. },
  200. {
  201. path: 'menu',
  202. component: () => import('@/views/sys/menu/index'), // Parent router-view
  203. name: 'menu',
  204. meta: { title: '菜单管理', pages: ['pc:system:menu:list'], icon: 'el-icon-collection-tag' }
  205. },
  206. {
  207. path: 'log',
  208. component: () => import('@/views/sys/log/index'), // Parent router-view
  209. name: 'log',
  210. meta: { title: '日志管理', pages: ['pc:system:operlog:list'], icon: 'el-icon-collection-tag' }
  211. }
  212. ]
  213. },
  214. {
  215. path: '*',
  216. redirect: '/404',
  217. hidden: true
  218. }
  219. ]
  220. const createRouter = () => new Router({
  221. mode: 'history', // require service support
  222. scrollBehavior: () => ({ y: 0 }),
  223. routes: constantRoutes
  224. })
  225. const router = createRouter()
  226. // Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
  227. export function resetRouter() {
  228. const newRouter = createRouter()
  229. router.matcher = newRouter.matcher // reset router
  230. }
  231. export default router