index.js 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. import Vue from 'vue'
  2. import Router from 'vue-router'
  3. // in development-env not use lazy-loading, because lazy-loading too many pages will cause webpack hot update too slow. so only in production use lazy-loading;
  4. // detail: https://panjiachen.github.io/vue-element-admin-site/#/lazy-loading
  5. Vue.use(Router)
  6. /* Layout */
  7. import Layout from '../views/layout/Layout'
  8. /**
  9. * hidden: true if `hidden:true` will not show in the sidebar(default is false)
  10. * alwaysShow: true if set true, will always show the root menu, whatever its child routes length
  11. * if not set alwaysShow, only more than one route under the children
  12. * it will becomes nested mode, otherwise not show the root menu
  13. * redirect: noredirect if `redirect:noredirect` will no redirct in the breadcrumb
  14. * name:'router-name' the name is used by <keep-alive> (must set!!!)
  15. * meta : {
  16. title: 'title' the name show in submenu and breadcrumb (recommend set)
  17. icon: 'svg-name' the icon show in the sidebar,
  18. }
  19. **/
  20. export const constantRouterMap = [
  21. { path: '/login', component: () => import('@/views/login/index'), hidden: true },
  22. { path: '/404', component: () => import('@/views/404'), hidden: true },
  23. {
  24. path: '/',
  25. component: Layout,
  26. redirect: '/dashboard',
  27. name: 'Dashboard',
  28. hidden: true,
  29. children: [{
  30. path: 'dashboard',
  31. component: () => import('@/views/dashboard/index')
  32. }]
  33. },
  34. {
  35. path: '/example',
  36. component: Layout,
  37. redirect: '/example/table',
  38. name: 'Example',
  39. meta: { title: 'Example', icon: 'example' },
  40. children: [
  41. {
  42. path: 'table',
  43. name: 'Table',
  44. component: () => import('@/views/table/index'),
  45. meta: { title: 'Table', icon: 'table' }
  46. },
  47. {
  48. path: 'tree',
  49. name: 'Tree',
  50. component: () => import('@/views/tree/index'),
  51. meta: { title: 'Tree', icon: 'tree' }
  52. }
  53. ]
  54. },
  55. {
  56. path: '/form',
  57. component: Layout,
  58. children: [
  59. {
  60. path: 'index',
  61. name: 'Form',
  62. component: () => import('@/views/form/index'),
  63. meta: { title: 'Form', icon: 'form' }
  64. }
  65. ]
  66. },
  67. {
  68. path: '/nested',
  69. component: Layout,
  70. redirect: '/nested/menu1',
  71. name: 'Nested',
  72. meta: {
  73. title: 'nested',
  74. icon: 'nested'
  75. },
  76. children: [
  77. {
  78. path: 'menu1',
  79. component: () => import('@/views/nested/menu1/index'), // Parent router-view
  80. name: 'Menu1',
  81. meta: { title: 'menu1' },
  82. children: [
  83. {
  84. path: 'menu1-1',
  85. component: () => import('@/views/nested/menu1/menu1-1'),
  86. name: 'Menu1-1',
  87. meta: { title: 'menu1-1' }
  88. },
  89. {
  90. path: 'menu1-2',
  91. component: () => import('@/views/nested/menu1/menu1-2'),
  92. name: 'Menu1-2',
  93. meta: { title: 'menu1-2' },
  94. children: [
  95. {
  96. path: 'menu1-2-1',
  97. component: () => import('@/views/nested/menu1/menu1-2/menu1-2-1'),
  98. name: 'Menu1-2-1',
  99. meta: { title: 'menu1-2-1' }
  100. },
  101. {
  102. path: 'menu1-2-2',
  103. component: () => import('@/views/nested/menu1/menu1-2/menu1-2-2'),
  104. name: 'Menu1-2-2',
  105. meta: { title: 'menu1-2-2' }
  106. }
  107. ]
  108. },
  109. {
  110. path: 'menu1-3',
  111. component: () => import('@/views/nested/menu1/menu1-3'),
  112. name: 'Menu1-3',
  113. meta: { title: 'menu1-3' }
  114. }
  115. ]
  116. },
  117. {
  118. path: 'menu2',
  119. component: () => import('@/views/nested/menu2/index'),
  120. meta: { title: 'menu2' }
  121. }
  122. ]
  123. },
  124. {
  125. path: 'external-link',
  126. component: Layout,
  127. children: [
  128. {
  129. path: 'https://panjiachen.github.io/vue-element-admin-site/#/',
  130. meta: { title: 'externalLink', icon: 'link' }
  131. }
  132. ]
  133. },
  134. { path: '*', redirect: '/404', hidden: true }
  135. ]
  136. export default new Router({
  137. // mode: 'history', //后端支持可开
  138. scrollBehavior: () => ({ y: 0 }),
  139. routes: constantRouterMap
  140. })