index.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. import Vue from 'vue'
  2. import Router from 'vue-router'
  3. Vue.use(Router)
  4. /* Layout */
  5. import Layout from '@/layout'
  6. /**
  7. * constantRoutes
  8. * a base page that does not have permission requirements
  9. * all roles can be accessed
  10. */
  11. export const constantRoutes = [
  12. {
  13. path: '/',
  14. component: Layout,
  15. redirect: '/dashboard',
  16. children: [
  17. {
  18. path: 'dashboard',
  19. component: () => import('@/views/dashboard/index'),
  20. name: 'Dashboard',
  21. meta: { title: '首页', icon: 'dashboard', affix: true }
  22. }
  23. ]
  24. },
  25. {
  26. path: '/maphydraulic',
  27. component: Layout,
  28. redirect: '/maphydraulic',
  29. children: [
  30. {
  31. path: 'maphydraulic',
  32. component: () => import('@/views/device/maintenance'),
  33. name: 'Maphydraulic',
  34. meta: { title: '泵设备分布图', icon: 'el-icon-location', affix: true }
  35. }
  36. ]
  37. },
  38. {
  39. path: '/Wind',
  40. component: Layout,
  41. redirect: '/Wind',
  42. children: [
  43. {
  44. path: 'Wind',
  45. component: () => import('@/views/device/maintenance'),
  46. name: 'Wind',
  47. meta: { title: '风场管理', icon: 'el-icon-wind-power', affix: true }
  48. }
  49. ]
  50. },
  51. {
  52. path: '/Maintenance',
  53. component: Layout,
  54. redirect: '/Maintenance',
  55. children: [
  56. {
  57. path: 'Maintenance',
  58. component: () => import('@/views/device/maintenance'),
  59. name: 'Maintenance',
  60. meta: { title: '维保记录', icon: 'el-icon-coin', affix: true }
  61. }
  62. ]
  63. },
  64. {
  65. path: '/login',
  66. component: () => import('@/views/login/index'),
  67. hidden: true
  68. },
  69. {
  70. path: '/profile',
  71. component: Layout,
  72. redirect: '/profile/index',
  73. hidden: true,
  74. children: [
  75. {
  76. path: 'index',
  77. component: () => import('@/views/profile/index'),
  78. name: '个人信息',
  79. meta: { title: '个人信息', icon: 'user', noCache: true }
  80. }
  81. ]
  82. }
  83. ]
  84. const createRouter = () => new Router({
  85. // mode: 'history', // require service support
  86. scrollBehavior: () => ({ y: 0 }),
  87. routes: constantRoutes
  88. })
  89. const router = createRouter()
  90. // Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
  91. export function resetRouter() {
  92. const newRouter = createRouter()
  93. router.matcher = newRouter.matcher // reset router
  94. }
  95. export default router