index.js 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  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: '/home',
  49. component: Home,
  50. name: '首页',
  51. hidden: true
  52. },
  53. // {
  54. // path: '/home',
  55. // component: Layout,
  56. // redirect: '/dashboard',
  57. // children: [{
  58. // path: 'dashboard',
  59. // name: 'Dashboard',
  60. // component: () => import('@/views/dashboard/index'),
  61. // meta: { title: 'Dashboard', icon: 'dashboard' }
  62. // }]
  63. // },
  64. {
  65. path: '/env-platform',
  66. component: Layout,
  67. redirect: '/env-platform/env',
  68. name: '环境',
  69. meta: { title: '环境平台', icon: 'env_platform' },
  70. children: [
  71. {
  72. path: 'env',
  73. name: 'env',
  74. component: () => import('@/views/env/index.vue'),
  75. meta: { title: '环境管理', icon: 'env' }
  76. },
  77. {
  78. path: 'businessline',
  79. name: 'businessline',
  80. component: () => import('@/views/env/index.vue'),
  81. meta: { title: '业务线管理', icon: 'businessline' }
  82. },
  83. {
  84. path: 'whitelist',
  85. name: 'whitelist',
  86. component: () => import('@/views/env/index.vue'),
  87. meta: { title: '白名单管理', icon: 'whitelist' }
  88. },
  89. {
  90. path: 'module',
  91. name: 'module',
  92. component: () => import('@/views/env/index.vue'),
  93. meta: { title: '模块管理', icon: 'module' }
  94. },
  95. {
  96. path: 'group',
  97. name: 'group',
  98. component: () => import('@/views/env/index.vue'),
  99. meta: { title: 'Group管理', icon: 'group' }
  100. },
  101. {
  102. path: 'topic',
  103. name: 'topic',
  104. component: () => import('@/views/env/index.vue'),
  105. meta: { title: 'Topic管理', icon: 'topic' }
  106. },
  107. {
  108. path: 'mq',
  109. name: 'mq',
  110. component: () => import('@/views/env/index.vue'),
  111. meta: { title: 'MQ管理', icon: 'MQ' }
  112. },
  113. {
  114. path: 'data',
  115. name: 'data',
  116. component: () => import('@/views/env/index.vue'),
  117. meta: { title: '数据统计', icon: 'data' }
  118. }
  119. ]
  120. },
  121. {
  122. path: '/mock',
  123. component: Layout,
  124. redirect: '/mock/interface',
  125. name: 'Mock',
  126. meta: { title: 'Mock服务', icon: 'example' },
  127. children: [
  128. {
  129. path: 'interface',
  130. name: 'Interface',
  131. component: () => import('@/views/mock/interface'),
  132. meta: { title: 'Mock服务', icon: 'interface' }
  133. },
  134. {
  135. path: 'interface/:rule',
  136. name: 'Rule',
  137. hidden: true,
  138. component: () => import('@/views/mock/rule'),
  139. meta: { title: '规则', icon: 'rule' }
  140. }
  141. ]
  142. },
  143. // {
  144. // path: '/form',
  145. // component: Layout,
  146. // children: [
  147. // {
  148. // path: 'index',
  149. // name: 'Form',
  150. // component: () => import('@/views/form/index'),
  151. // meta: { title: 'Form', icon: 'form' }
  152. // }
  153. // ]
  154. // },
  155. // 404 page must be placed at the end !!!
  156. { path: '*', redirect: '/404', hidden: true }
  157. ]
  158. const createRouter = () => new Router({
  159. // mode: 'history', // require service support
  160. scrollBehavior: () => ({ y: 0 }),
  161. routes: constantRoutes
  162. })
  163. const router = createRouter()
  164. // Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
  165. export function resetRouter() {
  166. const newRouter = createRouter()
  167. router.matcher = newRouter.matcher // reset router
  168. }
  169. export default router