index.js 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. import Vue from 'vue'
  2. import Router from 'vue-router'
  3. import Layout from '@/layout'
  4. Vue.use(Router)
  5. // 超级管理员
  6. import systemRouter from './modules/system'
  7. // 企业管理员
  8. import aqptRouter from './modules/aqpt'
  9. // 企业管理员
  10. import iiotRouter from './modules/iiot'
  11. export const constantRoutes = [
  12. {
  13. path: '/redirect',
  14. component: Layout,
  15. hidden: true,
  16. children: [
  17. {
  18. path: '/redirect/:path(.*)',
  19. component: () => import('@/views/redirect/index')
  20. }
  21. ]
  22. },
  23. {
  24. path: '/login',
  25. component: () => import('@/views/login/index'),
  26. hidden: true
  27. },
  28. {
  29. path: '/auth-redirect',
  30. component: () => import('@/views/login/auth-redirect'),
  31. hidden: true
  32. },
  33. {
  34. path: '/auth-test',
  35. component: Layout,
  36. hidden: true,
  37. children: [
  38. {
  39. path: '/test',
  40. component: () => import('@/views/test')
  41. }
  42. ]
  43. },
  44. {
  45. path: '/profile',
  46. component: Layout,
  47. redirect: '/profile/index',
  48. hidden: true,
  49. children: [
  50. {
  51. path: 'index',
  52. component: () => import('@/views/system/profile/userProfile'),
  53. name: 'Profile',
  54. meta: { title: '个人中心', icon: 'user', noCache: true }
  55. }
  56. ]
  57. },
  58. {
  59. path: '/404',
  60. component: Layout,
  61. hidden: true,
  62. children: [
  63. {
  64. path: '/404',
  65. component: () => import('@/views/404'),
  66. meta: { title: '404', icon: 'user', noCache: true }
  67. }
  68. ]
  69. }
  70. ]
  71. /**
  72. * asyncRoutes
  73. * the routes that need to be dynamically loaded based on user permits
  74. */
  75. export const asyncRoutes = [
  76. ...systemRouter,
  77. ...aqptRouter,
  78. ...iiotRouter,
  79. { path: '*', redirect: '/404', hidden: true }
  80. ]
  81. const createRouter = () => new Router({
  82. // mode: 'history', // require service support
  83. scrollBehavior: () => ({ y: 0 }),
  84. routes: constantRoutes
  85. })
  86. const router = createRouter()
  87. export function resetRouter() {
  88. const newRouter = createRouter()
  89. router.matcher = newRouter.matcher // reset router
  90. }
  91. export default router