index.js 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. import Vue from 'vue'
  2. import Router from 'vue-router'
  3. Vue.use(Router)
  4. /* Layout */
  5. import Layout from '@/layout'
  6. // import consoleRouter from './modules/console'
  7. // import systemRouter from './modules/system'
  8. // import dataExchangeRouter from "./modules/dataexchange"
  9. // import uploadRouter from './modules/uploadFile';
  10. /**
  11. * Note: sub-menu only appear when route children.length >= 1
  12. * Detail see: https://panjiachen.github.io/vue-element-admin-site/guide/essentials/router-and-nav.html
  13. *
  14. * hidden: true if set true, item will not show in the sidebar(default is false)
  15. * alwaysShow: true if set true, will always show the root menu
  16. * if not set alwaysShow, when item has more than one children route,
  17. * it will becomes nested mode, otherwise not show the root menu
  18. * redirect: noRedirect if set noRedirect will no redirect in the breadcrumb
  19. * name:'router-name' the name is used by <keep-alive> (must set!!!)
  20. * meta : {
  21. roles: ['admin','editor'] control the page roles (you can set multiple roles)
  22. title: 'title' the name show in sidebar and breadcrumb (recommend set)
  23. icon: 'svg-name' the icon show in the sidebar
  24. breadcrumb: false if set false, the item will hidden in breadcrumb(default is true)
  25. activeMenu: '/example/list' if set path, the sidebar will highlight the path you set
  26. }
  27. */
  28. /**
  29. * constantRoutes
  30. * a base page that does not have permission requirements
  31. * all roles can be accessed
  32. */
  33. export const constantRoutes = [
  34. {
  35. path: '/login',
  36. component: () => import('@/views/login/index'),
  37. hidden: true
  38. },
  39. {
  40. path: '/',
  41. component: Layout,
  42. redirect: '/dashboard',
  43. children: [{
  44. path: 'dashboard',
  45. name: '首页',
  46. component: () => import('@/views/dashboard/index'),
  47. meta: {title: '首页', icon: 'dashboard', affix: true}
  48. }]
  49. },
  50. {
  51. path: '/sysManager',
  52. component: Layout,
  53. redirect: '/sysManager',
  54. meta: {
  55. title: '系统管理'
  56. },
  57. children: [
  58. {
  59. path: 'userManager',
  60. name: '用户管理',
  61. component: () => import('@/views/sysManager/userManager/index'),
  62. meta: {title: '用户管理'}
  63. },
  64. {
  65. path: 'sysParameter',
  66. name: '参数管理',
  67. component: () => import('@/views/sysManager/sysParameter/index'),
  68. meta: {title: '参数管理'}
  69. }
  70. ,
  71. {
  72. path: 'sysMenu',
  73. name: '菜单管理',
  74. component: () => import('@/views/sysManager/sysMenu/index'),
  75. meta: {title: '菜单管理'}
  76. }
  77. ]
  78. },
  79. {
  80. path: '/404',
  81. component: () => import('@/views/404'),
  82. hidden: true
  83. },
  84. {
  85. path: '/user',
  86. component: Layout,
  87. hidden: true,
  88. redirect: 'noredirect',
  89. children: [
  90. {
  91. path: 'profile',
  92. component: () => import('@/views/sysManager/userManager/profile/index'),
  93. name: 'Profile',
  94. meta: {title: '个人中心', icon: 'user'}
  95. }
  96. ]
  97. },
  98. // consoleRouter,
  99. // systemRouter,
  100. // dataExchangeRouter,
  101. // uploadRouter,
  102. // 404 page must be placed at the end !!!
  103. {path: '*', redirect: '/404', hidden: true}
  104. ]
  105. const createRouter = () => new Router({
  106. // mode: 'history', // require service support
  107. scrollBehavior: () => ({y: 0}),
  108. routes: constantRoutes
  109. })
  110. const router = createRouter()
  111. // Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
  112. export function resetRouter() {
  113. const newRouter = createRouter()
  114. router.matcher = newRouter.matcher // reset router
  115. }
  116. export default router