index.js 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  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. path: '/login',
  31. component: () => import('@/views/login/index'),
  32. hidden: true
  33. },
  34. {
  35. path: '/404',
  36. component: () => import('@/views/404'),
  37. hidden: true
  38. },
  39. {
  40. path: '/',
  41. component: Layout,
  42. redirect: '/dashboard',
  43. children: [{
  44. path: 'dashboard',
  45. name: 'Dashboard',
  46. component: () => import('@/views/dashboard/index'),
  47. meta: {
  48. title: '数据看板',
  49. icon: 'dashboard'
  50. }
  51. }]
  52. },
  53. {
  54. path: '/user',
  55. component: Layout,
  56. props: true,
  57. meta: {
  58. roles: ['admin'],
  59. title: "用户管理",
  60. icon: 'user',
  61. },
  62. children: [{
  63. path: 'index',
  64. name: 'user',
  65. component: () => import('@/views/user/index'),
  66. meta: {
  67. title: '用户管理',
  68. icon: 'user'
  69. }
  70. }]
  71. },
  72. // {
  73. // path: '/role',
  74. // component: Layout,
  75. // children: [
  76. // {
  77. // path: 'index',
  78. // name: 'role',
  79. // component: () => import('@/views/role/index'),
  80. // meta: { title: '角色管理', icon: 'role' }
  81. // }
  82. // ]
  83. // },
  84. {
  85. path: '/sys-param',
  86. component: Layout,
  87. meta: {
  88. roles: ['admin'],
  89. title: "系统参数",
  90. icon: 'sys-param',
  91. },
  92. children: [{
  93. path: 'index',
  94. name: 'sys-param',
  95. component: () => import('@/views/sys-param/index'),
  96. meta: {
  97. title: '系统参数',
  98. icon: 'sys-param'
  99. }
  100. }]
  101. },
  102. {
  103. path: '/autoplay',
  104. component: Layout,
  105. meta: {
  106. title: '任务管理',
  107. icon: 'autoplay'
  108. },
  109. children: [{
  110. path: 'index',
  111. name: 'autoplay',
  112. component: () => import('@/views/autoplay/index'),
  113. meta: {
  114. title: '任务管理',
  115. icon: 'autoplay'
  116. }
  117. }]
  118. },
  119. {
  120. path: '/airdrop',
  121. component: Layout,
  122. children: [{
  123. path: 'index',
  124. name: 'airdrop',
  125. component: () => import('@/views/airdrop/index'),
  126. meta: {
  127. title: '项目管理',
  128. icon: 'airdrop'
  129. }
  130. }]
  131. },
  132. // {
  133. // path: '/strategy',
  134. // component: Layout,
  135. // children: [{
  136. // path: 'index',
  137. // name: 'strategy',
  138. // component: () => import('@/views/strategy/index'),
  139. // meta: {
  140. // title: '策略管理',
  141. // icon: 'strategy'
  142. // }
  143. // }]
  144. // },
  145. {
  146. path: '/address',
  147. component: Layout,
  148. children: [{
  149. path: 'index',
  150. name: 'address',
  151. component: () => import('@/views/address/index'),
  152. meta: {
  153. title: '地址管理',
  154. icon: 'address'
  155. }
  156. }]
  157. },
  158. // 404 page must be placed at the end !!!
  159. {
  160. path: '*',
  161. redirect: '/404',
  162. hidden: true
  163. }
  164. ]
  165. const createRouter = () => new Router({
  166. // mode: 'history', // require service support
  167. scrollBehavior: () => ({
  168. y: 0
  169. }),
  170. routes: constantRoutes
  171. })
  172. const router = createRouter()
  173. // Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
  174. export function resetRouter() {
  175. const newRouter = createRouter()
  176. router.matcher = newRouter.matcher // reset router
  177. }
  178. export default router