小说后台管理系统
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

141 line
4.0 KiB

  1. import Vue from 'vue'
  2. import Router from 'vue-router'
  3. Vue.use(Router)
  4. /* Layout */
  5. import Layout from '@/layout'
  6. /* Router Modules */
  7. import componentsRouter from './modules/components'
  8. import chartsRouter from './modules/charts'
  9. // import nestedRouter from './modules/nested'
  10. import memberManagement from './modules/member-management'
  11. import booksManagement from './modules/books-management'
  12. import sortManagement from './modules/sort-management'
  13. import basicSetting from './modules/basic-setting'
  14. import setAdvertising from './modules/set-advertising'
  15. import home from './modules/home'
  16. import mobTemplate from './modules/push-settings'
  17. // import systemManagementRouter from './modules/system-management'
  18. /**
  19. * Note: sub-menu only appear when route children.length >= 1
  20. * Detail see: https://panjiachen.github.io/vue-element-admin-site/guide/essentials/router-and-nav.html
  21. *
  22. * hidden: true if set true, item will not show in the sidebar(default is false)
  23. * alwaysShow: true if set true, will always show the root menu
  24. * if not set alwaysShow, when item has more than one children route,
  25. * it will becomes nested mode, otherwise not show the root menu
  26. * redirect: noRedirect if set noRedirect will no redirect in the breadcrumb
  27. * name:'router-name' the name is used by <keep-alive> (must set!!!)
  28. * meta : {
  29. roles: ['admin','editor'] control the page roles (you can set multiple roles)
  30. title: 'title' the name show in sidebar and breadcrumb (recommend set)
  31. icon: 'svg-name'/'el-icon-x' the icon show in the sidebar
  32. noCache: true if set true, the page will no be cached(default is false)
  33. affix: true if set true, the tag will affix in the tags-view
  34. breadcrumb: false if set false, the item will hidden in breadcrumb(default is true)
  35. activeMenu: '/example/list' if set path, the sidebar will highlight the path you set
  36. }
  37. */
  38. /**
  39. * constantRoutes
  40. * a base page that does not have permission requirements
  41. * all roles can be accessed
  42. */
  43. export const constantRoutes = [
  44. {
  45. path: '/redirect',
  46. component: Layout,
  47. hidden: true,
  48. children: [
  49. {
  50. path: '/redirect/:path(.*)',
  51. component: () => import('@/views/redirect/index')
  52. }
  53. ]
  54. },
  55. {
  56. path: '/login',
  57. component: () => import('@/views/login/index'),
  58. hidden: true
  59. },
  60. {
  61. path: '/auth-redirect',
  62. component: () => import('@/views/login/auth-redirect'),
  63. hidden: true
  64. },
  65. {
  66. path: '/404',
  67. component: () => import('@/views/error-page/404'),
  68. hidden: true
  69. },
  70. {
  71. path: '/401',
  72. component: () => import('@/views/error-page/401'),
  73. hidden: true
  74. },
  75. ]
  76. /**
  77. * asyncRoutes
  78. * the routes that need to be dynamically loaded based on user roles
  79. */
  80. export const asyncRoutes = [
  81. home,
  82. basicSetting,
  83. memberManagement,
  84. booksManagement,
  85. sortManagement,
  86. setAdvertising,
  87. mobTemplate,
  88. // 404 page must be placed at the end !!!
  89. { path: '*', redirect: '/404', hidden: true }
  90. ]
  91. if (process.env.NODE_ENV === 'development') {
  92. console.log('开发环境, 添加组件列表方便开发')
  93. asyncRoutes.splice(0, 0, chartsRouter)
  94. // asyncRoutes.splice(0, 0, nestedRouter)
  95. asyncRoutes.splice(0, 0, componentsRouter)
  96. asyncRoutes.splice(0, 0, {
  97. path: '/icon',
  98. component: Layout,
  99. children: [
  100. {
  101. path: 'index',
  102. component: () => import('@/views/icons/index'),
  103. name: 'Icons',
  104. meta: { title: 'icons', icon: 'icon', noCache: true }
  105. }
  106. ]
  107. })
  108. }
  109. const createRouter = () =>
  110. new Router({
  111. // mode: 'history', // require service support
  112. scrollBehavior: () => ({ y: 0 }),
  113. routes: constantRoutes
  114. })
  115. const router = createRouter()
  116. // Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
  117. export function resetRouter() {
  118. const newRouter = createRouter()
  119. router.matcher = newRouter.matcher // reset router
  120. }
  121. export default router