index.js 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. import Vue from 'vue'
  2. import Router from 'vue-router'
  3. Vue.use(Router)
  4. /* Layout */
  5. import Layout from '@/layout'
  6. /* Home */
  7. import Home from '@/views/home/index'
  8. /**
  9. * Note: sub-menu only appear when route children.length >= 1
  10. * Detail see: https://panjiachen.github.io/vue-element-admin-site/guide/essentials/router-and-nav.html
  11. *
  12. * hidden: true if set true, item will not show in the sidebar(default is false)
  13. * alwaysShow: true if set true, will always show the root menu
  14. * if not set alwaysShow, when item has more than one children route,
  15. * it will becomes nested mode, otherwise not show the root menu
  16. * redirect: noRedirect if set noRedirect will no redirect in the breadcrumb
  17. * name:'router-name' the name is used by <keep-alive> (must set!!!)
  18. * meta : {
  19. roles: ['admin','editor'] control the page roles (you can set multiple roles)
  20. title: 'title' the name show in sidebar and breadcrumb (recommend set)
  21. icon: 'svg-name' the icon show in the sidebar
  22. breadcrumb: false if set false, the item will hidden in breadcrumb(default is true)
  23. activeMenu: '/example/list' if set path, the sidebar will highlight the path you set
  24. }
  25. */
  26. /**
  27. * constantRoutes
  28. * a base page that does not have permission requirements
  29. * all roles can be accessed
  30. */
  31. export const constantRoutes = [
  32. {
  33. path: '/login',
  34. component: () => import('@/views/login/index'),
  35. hidden: true
  36. },
  37. {
  38. path: '/404',
  39. component: () => import('@/views/404'),
  40. hidden: true
  41. },
  42. {
  43. path: '/',
  44. component: Home,
  45. hidden: true
  46. },
  47. {
  48. path: '/',
  49. component: Layout,
  50. redirect: '/dashboard',
  51. children: [{
  52. path: 'dashboard',
  53. name: 'Dashboard',
  54. component: () => import('@/views/dashboard/index'),
  55. meta: { title: 'Dashboard', icon: 'dashboard' }
  56. }]
  57. },
  58. {
  59. path: '/mock',
  60. component: Layout,
  61. redirect: '/mock/interface',
  62. name: 'Mock',
  63. meta: { title: 'Mock服务', icon: 'example' },
  64. children: [
  65. {
  66. path: 'interface',
  67. name: 'Interface',
  68. component: () => import('@/views/mock/interface'),
  69. meta: { title: '接口', icon: 'interface' }
  70. },
  71. {
  72. path: 'interface/:rule',
  73. name: 'Rule',
  74. component: () => import('@/views/mock/rule'),
  75. meta: { title: '规则', icon: 'rule' }
  76. }
  77. ]
  78. },
  79. {
  80. path: '/env-platform',
  81. component: Layout,
  82. redirect: '/env-platform/env',
  83. name: '环境',
  84. meta: { title: '环境平台', icon: 'env_platform' },
  85. children: [
  86. {
  87. path: 'env',
  88. name: 'env',
  89. component: () => import('@/views/env/index.vue'),
  90. meta: { title: '环境管理', icon: 'env' }
  91. },
  92. {
  93. path: 'businessline',
  94. name: 'businessline',
  95. component: () => import('@/views/env/index.vue'),
  96. meta: { title: '业务线管理', icon: 'businessline' }
  97. },
  98. {
  99. path: 'whitelist',
  100. name: 'whitelist',
  101. component: () => import('@/views/env/index.vue'),
  102. meta: { title: '白名单管理', icon: 'whitelist' }
  103. },
  104. {
  105. path: 'module',
  106. name: 'module',
  107. component: () => import('@/views/env/index.vue'),
  108. meta: { title: '模块管理', icon: 'module' }
  109. },
  110. {
  111. path: 'group',
  112. name: 'group',
  113. component: () => import('@/views/env/index.vue'),
  114. meta: { title: 'Group管理', icon: 'group' }
  115. },
  116. {
  117. path: 'topic',
  118. name: 'topic',
  119. component: () => import('@/views/env/index.vue'),
  120. meta: { title: 'Topic管理', icon: 'topic' }
  121. },
  122. {
  123. path: 'mq',
  124. name: 'mq',
  125. component: () => import('@/views/env/index.vue'),
  126. meta: { title: 'MQ管理', icon: 'MQ' }
  127. },
  128. {
  129. path: 'data',
  130. name: 'data',
  131. component: () => import('@/views/env/index.vue'),
  132. meta: { title: '数据统计', icon: 'data' }
  133. }
  134. ]
  135. },
  136. // {
  137. // path: '/form',
  138. // component: Layout,
  139. // children: [
  140. // {
  141. // path: 'index',
  142. // name: 'Form',
  143. // component: () => import('@/views/form/index'),
  144. // meta: { title: 'Form', icon: 'form' }
  145. // }
  146. // ]
  147. // },
  148. // 404 page must be placed at the end !!!
  149. { path: '*', redirect: '/404', hidden: true }
  150. ]
  151. const createRouter = () => new Router({
  152. // mode: 'history', // require service support
  153. scrollBehavior: () => ({ y: 0 }),
  154. routes: constantRoutes
  155. })
  156. const router = createRouter()
  157. // Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
  158. export function resetRouter() {
  159. const newRouter = createRouter()
  160. router.matcher = newRouter.matcher // reset router
  161. }
  162. export default router