|
@@ -1,106 +1,106 @@
|
|
|
-import Vue from "vue"
|
|
|
-import store from "@/store"
|
|
|
-import VueRouter from "vue-router"
|
|
|
-import {
|
|
|
- query
|
|
|
-} from "@/utils/query"
|
|
|
+import Vue from 'vue'
|
|
|
+import store from '@/store'
|
|
|
+import VueRouter from 'vue-router'
|
|
|
+import { query } from '@/utils/query'
|
|
|
Vue.use(VueRouter)
|
|
|
|
|
|
const routes = [
|
|
|
// 登陆页面
|
|
|
{
|
|
|
- path: "/",
|
|
|
- redirect: "/home/overview",
|
|
|
+ path: '/',
|
|
|
+ redirect: '/home/overview',
|
|
|
},
|
|
|
{
|
|
|
- path: "/404",
|
|
|
- component: () => import("../components/404"),
|
|
|
+ path: '/404',
|
|
|
+ component: () => import('../components/404'),
|
|
|
},
|
|
|
// home
|
|
|
{
|
|
|
- path: "/home",
|
|
|
- name: "home",
|
|
|
- component: () => import("../views/index"),
|
|
|
- redirect: "/home/first",
|
|
|
- children: [{
|
|
|
- path: "first",
|
|
|
- component: () => import("../views/first"),
|
|
|
+ path: '/home',
|
|
|
+ name: 'home',
|
|
|
+ component: () => import('../views/index'),
|
|
|
+ redirect: '/home/first',
|
|
|
+ children: [
|
|
|
+ {
|
|
|
+ path: 'first',
|
|
|
+ component: () => import('../views/first'),
|
|
|
},
|
|
|
//概览
|
|
|
{
|
|
|
- path: "overview",
|
|
|
- component: () => import("../views/overview"),
|
|
|
+ path: 'overview',
|
|
|
+ component: () => import('../views/overview'),
|
|
|
},
|
|
|
// 楼层功能
|
|
|
{
|
|
|
- path: "floorFunc",
|
|
|
- component: () => import("../views/floorFunc"),
|
|
|
+ path: 'floorFunc',
|
|
|
+ component: () => import('../views/floorFunc'),
|
|
|
},
|
|
|
// 设备设施
|
|
|
{
|
|
|
- path: "equipment",
|
|
|
- component: () => import("../views/equipment"),
|
|
|
+ path: 'equipment',
|
|
|
+ component: () => import('../views/equipment'),
|
|
|
},
|
|
|
// 其他功能
|
|
|
{
|
|
|
- path: "other",
|
|
|
- component: () => import("../views/other"),
|
|
|
+ path: 'other',
|
|
|
+ component: () => import('../views/other'),
|
|
|
},
|
|
|
// 分析
|
|
|
{
|
|
|
- path: "analysis",
|
|
|
- component: () => import("../views/analysis"),
|
|
|
+ path: 'analysis',
|
|
|
+ component: () => import('../views/analysis'),
|
|
|
},
|
|
|
//图例库管理
|
|
|
{
|
|
|
- path: "legendLibrary",
|
|
|
- component: () => import("../views/legendLibrary"),
|
|
|
+ path: 'legendLibrary',
|
|
|
+ component: () => import('../views/legendLibrary'),
|
|
|
},
|
|
|
//图例绘制规则
|
|
|
{
|
|
|
- path: "legendRules",
|
|
|
- component: () => import("../views/legendRules"),
|
|
|
+ path: 'legendRules',
|
|
|
+ component: () => import('../views/legendRules'),
|
|
|
},
|
|
|
],
|
|
|
},
|
|
|
]
|
|
|
const router = new VueRouter({
|
|
|
- mode: "history",
|
|
|
+ mode: 'history',
|
|
|
base: process.env.BASE_URL,
|
|
|
routes,
|
|
|
})
|
|
|
//不需要token的路由
|
|
|
-const ignore = ["/404", "/legendLibrary", "/legendRules"]
|
|
|
+const ignore = ['/404', '/legendLibrary', '/legendRules']
|
|
|
router.beforeEach(async (to, from, next) => {
|
|
|
- if (!ignore.includes(to.path)) {
|
|
|
- const token = query().token
|
|
|
- const ssoToken = store.getters["ssoToken"]
|
|
|
- if (ssoToken) {
|
|
|
- store.commit("SETSSOTOKEN", ssoToken)
|
|
|
- await store.dispatch("getUserInfo", router)
|
|
|
- await store.dispatch("getFloors")
|
|
|
- await store.dispatch("getBrand")
|
|
|
- next()
|
|
|
- } else if (token) {
|
|
|
- store.commit("SETSSOTOKEN", token)
|
|
|
- await store.dispatch("getUserInfo", router)
|
|
|
- next()
|
|
|
- } else {
|
|
|
- let lastRoute = {
|
|
|
- path: to.path,
|
|
|
- params: to.params,
|
|
|
- query: to.query,
|
|
|
- }
|
|
|
- store.commit("SETLASTROUTER", lastRoute)
|
|
|
- let ssoServer = "http://oauth.wanda-dev.cn"
|
|
|
- let systemcode = "CAD156",
|
|
|
- signal = new Date().getTime(),
|
|
|
- version = "1.0.0"
|
|
|
- window.location.href = `${ssoServer}/login?systemcode=${systemcode}&signal=${signal}&version=${version}`
|
|
|
- }
|
|
|
- } else {
|
|
|
- next()
|
|
|
- return
|
|
|
- }
|
|
|
+ // if (!ignore.includes(to.path)) {
|
|
|
+ // const token = query().token
|
|
|
+ // const ssoToken = store.getters["ssoToken"]
|
|
|
+ // if (ssoToken) {
|
|
|
+ // store.commit("SETSSOTOKEN", ssoToken)
|
|
|
+ // await store.dispatch('getUserInfo', router)
|
|
|
+ await store.dispatch('getFloors')
|
|
|
+ await store.dispatch('getBrand')
|
|
|
+ // next()
|
|
|
+ // } else if (token) {
|
|
|
+ // store.commit("SETSSOTOKEN", token)
|
|
|
+ // await store.dispatch("getUserInfo", router)
|
|
|
+ // next()
|
|
|
+ // } else {
|
|
|
+ // let lastRoute = {
|
|
|
+ // path: to.path,
|
|
|
+ // params: to.params,
|
|
|
+ // query: to.query,
|
|
|
+ // }
|
|
|
+ // store.commit("SETLASTROUTER", lastRoute)
|
|
|
+ // let ssoServer = "http://oauth.wanda-dev.cn"
|
|
|
+ // let systemcode = "CAD156",
|
|
|
+ // signal = new Date().getTime(),
|
|
|
+ // version = "1.0.0"
|
|
|
+ // window.location.href = `${ssoServer}/login?systemcode=${systemcode}&signal=${signal}&version=${version}`
|
|
|
+ // }
|
|
|
+ // } else {
|
|
|
+ // next()
|
|
|
+ // return
|
|
|
+ // }
|
|
|
+ next()
|
|
|
})
|
|
|
-export default router
|
|
|
+export default router
|