index.js 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. import Vue from 'vue'
  2. import store from '@/store'
  3. import VueRouter from 'vue-router'
  4. import { query } from '@/utils/query'
  5. Vue.use(VueRouter)
  6. const routes = [
  7. // 登陆页面
  8. {
  9. path: '/',
  10. redirect: '/home/overview',
  11. },
  12. {
  13. path: '/404',
  14. component: () => import('../components/404'),
  15. },
  16. {
  17. path: '/group',
  18. component: () => import('../views/statistics/index'),
  19. },
  20. // home
  21. {
  22. path: '/home',
  23. name: 'home',
  24. component: () => import('../views/index'),
  25. redirect: '/home/homepage',
  26. children: [
  27. {
  28. path: 'homepage',
  29. component: () => import('../views/homepage'),
  30. },
  31. //概览
  32. {
  33. path: 'overview',
  34. component: () => import('../views/overview'),
  35. },
  36. // 楼层功能
  37. {
  38. path: 'floorFunc',
  39. component: () => import('../views/floorFunc'),
  40. },
  41. // 设备设施
  42. {
  43. path: 'equipment',
  44. component: () => import('../views/equipment'),
  45. },
  46. // 其他功能
  47. {
  48. path: 'other',
  49. component: () => import('../views/other'),
  50. },
  51. // 分析
  52. {
  53. path: 'analysis',
  54. component: () => import('../views/analysis'),
  55. },
  56. //图例库管理
  57. {
  58. path: 'legendLibrary',
  59. component: () => import('../views/legendLibrary'),
  60. },
  61. //图例绘制规则
  62. {
  63. path: 'legendRules',
  64. component: () => import('../views/legendRules'),
  65. },
  66. ],
  67. },
  68. ]
  69. const router = new VueRouter({
  70. mode: 'history',
  71. base: process.env.BASE_URL,
  72. routes,
  73. })
  74. //不需要token的路由
  75. const ignore = ['/404']
  76. router.beforeEach(async (to, from, next) => {
  77. // if (!ignore.includes(to.path)) {
  78. // const token = query().token
  79. // const ssoToken = store.getters['ssoToken']
  80. // if (ssoToken) {
  81. // store.commit('SETSSOTOKEN', ssoToken)
  82. // await store.dispatch('getUserInfo', router)
  83. await store.dispatch('getFloors')
  84. await store.dispatch('getBrand')
  85. // next()
  86. // } else if (token) {
  87. // store.commit('SETSSOTOKEN', token)
  88. // await store.dispatch('getUserInfo', router)
  89. // next()
  90. // } else {
  91. // let lastRoute = {
  92. // path: to.path,
  93. // params: to.params,
  94. // query: to.query,
  95. // }
  96. // store.commit('SETLASTROUTER', lastRoute)
  97. // let ssoServer = 'http://oauth.wanda-dev.cn'
  98. // let systemcode = 'CAD156',
  99. // signal = new Date().getTime(),
  100. // version = '1.0.0',
  101. // returnUrl = window.location.protocol + '//' + window.location.host
  102. // window.location.href = `${ssoServer}/login?systemcode=${systemcode}&signal=${signal}&version=${version}`
  103. // }
  104. // } else {
  105. next()
  106. // return
  107. // }
  108. })
  109. export default router