index.js 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. import Vue from 'vue'
  2. import Router from 'vue-router'
  3. import main from '@/pages/other/index'
  4. Vue.use(Router)
  5. /* Layout */
  6. import Layout from '@/layout'
  7. // /* Router Modules */
  8. // import componentsRouter from './modules/components'
  9. // import chartsRouter from './modules/charts'
  10. // import tableRouter from './modules/table'
  11. // import nestedRouter from './modules/nested'
  12. /**
  13. * Note: sub-menu only appear when route children.length >= 1
  14. * Detail see: https://panjiachen.github.io/vue-element-admin-site/guide/essentials/router-and-nav.html
  15. *
  16. * hidden: true if set true, item will not show in the sidebar(default is false)
  17. * alwaysShow: true if set true, will always show the root menu
  18. * if not set alwaysShow, when item has more than one children route,
  19. * it will becomes nested mode, otherwise not show the root menu
  20. * redirect: noRedirect if set noRedirect will no redirect in the breadcrumb
  21. * name:'router-name' the name is used by <keep-alive> (must set!!!)
  22. * meta : {
  23. roles: ['admin','editor'] control the page roles (you can set multiple roles)
  24. title: 'title' the name show in sidebar and breadcrumb (recommend set)
  25. icon: 'svg-name'/'el-icon-x' the icon show in the sidebar
  26. noCache: true if set true, the page will no be cached(default is false)
  27. affix: true if set true, the tag will affix in the tags-view
  28. breadcrumb: false if set false, the item will hidden in breadcrumb(default is true)
  29. activeMenu: '/example/list' if set path, the sidebar will highlight the path you set
  30. }
  31. */
  32. /**
  33. * constantRoutes
  34. * a base page that does not have permission requirements
  35. * all roles can be accessed
  36. */
  37. export const constantRoutes = [
  38. {
  39. path: '/login',
  40. component: () => import('@/pages/login/index'),
  41. hidden: true
  42. },
  43. {
  44. path: '/auth-redirect',
  45. component: () => import('@/pages/login/auth-redirect'),
  46. hidden: true
  47. },
  48. {
  49. path: '/200',
  50. component: () => import('@/pages/error-page/200'),
  51. name: 'page200',
  52. hidden: true
  53. },
  54. {
  55. path: '/404',
  56. component: () => import('@/pages/error-page/404'),
  57. hidden: true
  58. },
  59. {
  60. path: '/401',
  61. component: () => import('@/pages/error-page/401'),
  62. hidden: true
  63. },
  64. {
  65. path: '/file-manage',
  66. component: () => import('@/pages/other/file-manage'),
  67. hidden: true
  68. },
  69. {
  70. path: '/',
  71. redirect: '/file-manage',
  72. hidden: true
  73. },
  74. {
  75. path: '/user',
  76. name: 'user',
  77. component: main,
  78. children: [{
  79. path: '/apply-list',
  80. component: () => import('@/pages/other/apply-list'),
  81. hidden: true
  82. },
  83. {
  84. path: '/reply-list',
  85. component: () => import('@/pages/other/reply-list'),
  86. hidden: true
  87. },
  88. {
  89. path: '/file-search',
  90. component: () => import('@/pages/other/file-search'),
  91. hidden: true
  92. },
  93. {
  94. path: '/my-file',
  95. component: () => import('@/pages/other/my-file'),
  96. hidden: true
  97. },
  98. {
  99. path: '/reset',
  100. name:'reset',
  101. component: () => import('@/pages/other/reset'),
  102. hidden: true
  103. },
  104. {
  105. path: '/file-add',
  106. component: () => import('@/pages/other/file-add'),
  107. hidden: true
  108. },
  109. {
  110. path: '/file-confirm',
  111. component: () => import('@/pages/other/file-confirm'),
  112. hidden: true
  113. },
  114. {
  115. path: '/file-publish',
  116. component: () => import('@/pages/other/file-publish'),
  117. hidden: true
  118. },
  119. {
  120. path: '/file-info',
  121. component: () => import('@/pages/other/file-info'),
  122. hidden: true
  123. }
  124. ],
  125. }
  126. ]
  127. /**
  128. * asyncRoutes
  129. * the routes that need to be dynamically loaded based on user roles
  130. */
  131. export const asyncRoutes = [
  132. // 404 page must be placed at the end !!!
  133. {
  134. path: '*',
  135. redirect: '/404',
  136. hidden: true
  137. }
  138. ]
  139. const createRouter = () => new Router({
  140. // mode: 'history', // require service support
  141. scrollBehavior: () => ({
  142. y: 0
  143. }),
  144. routes: constantRoutes
  145. })
  146. const router = createRouter()
  147. // Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
  148. export function resetRouter() {
  149. const newRouter = createRouter()
  150. router.matcher = newRouter.matcher // reset router
  151. }
  152. export default router