YaolongHan 4 years ago
parent
commit
8d529fd6ba
2 changed files with 94 additions and 94 deletions
  1. 93 93
      src/router/index.js
  2. 1 1
      src/views/analysis/GanttChart.vue

+ 93 - 93
src/router/index.js

@@ -15,10 +15,10 @@ import {
 } from "@/api/public.js"
 Vue.use(VueRouter)
 const routes = [
-    {
-        path: '/',
-        redirect: '/home/overview', // 只有区域,及区域以上用户才能进入总部首页这一套
-    },
+    // {
+    //     path: '/',
+    //     redirect: '/home/overview', // 只有区域,及区域以上用户才能进入总部首页这一套
+    // },
     {
         path: "/404",
         name: "404页面",
@@ -40,7 +40,7 @@ const routes = [
                 name: "项目首页",
                 component: () => import("../views/homepage"),
                 // TODO: 注释重定向到预览页面,liujiandong用户 路由跳转处理
-                // redirect: "/home/overview", 
+                // redirect: "/home/overview",
                 beforeEnter (to,from,next){
                     if (store.state.userInfo.username !== 'liujiandong') {
                         next('/home/overview')
@@ -101,99 +101,99 @@ const router = new VueRouter({
 })
 const ignore = ["/404"]
 
-// router.beforeEach(async (to, from, next) => {
+router.beforeEach(async (to, from, next) => {
 
-//     // 如果路径上有plazaId就保存
-//     let plazaId = to.query.plazaId ?to.query.plazaId:''
-//     if (plazaId) {
-//         localStorage.setItem('PLAZAID', plazaId)
-//         store.commit('STOREPLAZAID', plazaId);
-//     }
-//     let previewUrl = to.query.isPreview ? to.query.isPreview : '';
-//     if (previewUrl) {
-//         sessionStorage.setItem("SETISPREVIEW", previewUrl)
-//         store.commit('SETISPREVIEW', previewUrl)
-//     }
-//     // 取出刷新时的 ssoToken, 路由拦截时app.vue 生命周期还没有执行,store中还没有数据,
-//     let beforeunload = localStorage.getItem("beforeunload"),
-//         __token = null
-//     beforeunload && (__token = JSON.parse(beforeunload).ssoToken)
-//     if (!ignore.includes(to.path)) {
-//         //都是需要token检验的页面 首先优先获取路由上带的token
-//         let token = null
-//         if (to.query.token) {
-//             store.commit("SETSSOTOKEN", to.query.token) //存vuex
-//             sessionStorage.setItem("SSOTOKEN", to.query.token)
-//             token = to.query.token
-//         } else {
-//             if (store.getters["ssoToken"]) {
-//                 token = store.getters["ssoToken"]
-//             } else if (sessionStorage.getItem("SSOTOKEN")) {
-//                 token = sessionStorage.getItem("SSOTOKEN")
-//                 store.commit("SETSSOTOKEN", sessionStorage.getItem("SSOTOKEN")) //存vuex
-//             } else {
-//                 redirectGetToken(to,from)
-//             }
-//         }
-//         // 如果有token
-//         if (token) {
-//             // 有token 将数据 isPreview赋给 vuex方便取值
-//             store.commit('SETISPREVIEW', sessionStorage.getItem("SETISPREVIEW"))
-//             // 如果在跳转获取token之前保存了指定的路径,则后去token后需要跳转到相关页面
+    // 如果路径上有plazaId就保存
+    let plazaId = to.query.plazaId ?to.query.plazaId:''
+    if (plazaId) {
+        localStorage.setItem('PLAZAID', plazaId)
+        store.commit('STOREPLAZAID', plazaId);
+    }
+    let previewUrl = to.query.isPreview ? to.query.isPreview : '';
+    if (previewUrl) {
+        sessionStorage.setItem("SETISPREVIEW", previewUrl)
+        store.commit('SETISPREVIEW', previewUrl)
+    }
+    // 取出刷新时的 ssoToken, 路由拦截时app.vue 生命周期还没有执行,store中还没有数据,
+    let beforeunload = localStorage.getItem("beforeunload"),
+        __token = null
+    beforeunload && (__token = JSON.parse(beforeunload).ssoToken)
+    if (!ignore.includes(to.path)) {
+        //都是需要token检验的页面 首先优先获取路由上带的token
+        let token = null
+        if (to.query.token) {
+            store.commit("SETSSOTOKEN", to.query.token) //存vuex
+            sessionStorage.setItem("SSOTOKEN", to.query.token)
+            token = to.query.token
+        } else {
+            if (store.getters["ssoToken"]) {
+                token = store.getters["ssoToken"]
+            } else if (sessionStorage.getItem("SSOTOKEN")) {
+                token = sessionStorage.getItem("SSOTOKEN")
+                store.commit("SETSSOTOKEN", sessionStorage.getItem("SSOTOKEN")) //存vuex
+            } else {
+                redirectGetToken(to,from)
+            }
+        }
+        // 如果有token
+        if (token) {
+            // 有token 将数据 isPreview赋给 vuex方便取值
+            store.commit('SETISPREVIEW', sessionStorage.getItem("SETISPREVIEW"))
+            // 如果在跳转获取token之前保存了指定的路径,则后去token后需要跳转到相关页面
 
-//             if(to.path !='/group' && to.path !='/home/homepage' && to.path !='/' ){
-//                 if(!store.state.permissions || store.state.permissions.length ==0){
-//                     // 如果没有请求permissions则请求getUserInfo
-//                     await store.dispatch("getUserInfoNoPath", router)
-//                 }
-//             }
+            if(to.path !='/group' && to.path !='/home/homepage' && to.path !='/' ){
+                if(!store.state.permissions || store.state.permissions.length ==0){
+                    // 如果没有请求permissions则请求getUserInfo
+                    await store.dispatch("getUserInfoNoPath", router)
+                }
+            }
 
-//             if (sessionStorage.getItem("TOURL")) {
-//                 // 如果去的地址等于缓存的地址
-//                 if (sessionStorage.getItem("TOURL") == to.path) {
-//                     sessionStorage.setItem("TOURL", '')
-//                     if (to.path == "/") {
-//                         next("/group")
-//                     }
-//                     if (to.path == "/group" || to.path == "/home/homepage") {
-//                         if (store.state.accessLevel == -1) {
-//                             await store.dispatch("getUserInfo", router)
-//                             await store.dispatch("getBrand")
-//                             // await store.dispatch('getFact')
-//                         }
-//                     }
-//                     await store.dispatch("getFloors")
-//                     await store.dispatch("getBrand")
-//                     next()
-//                 } else {
-//                     next(sessionStorage.getItem("TOURL"))
-//                 }
-//             } else {
-//                 if (to.path == "/") {
-//                     next("/group")
-//                 }
-//                 if (to.path == "/group" || to.path == "/home/homepage") {
-//                     if (store.state.accessLevel == -1) {
-//                         await store.dispatch("getUserInfo", router)
-//                         console.log('getUserInfo', 4)
-//                         await store.dispatch("getBrand")
-//                         // await store.dispatch('getFact')
-//                     }
-//                 }
-//                 await store.dispatch("getFloors")
-//                 await store.dispatch("getBrand")
-//                 next()
-//             }
+            if (sessionStorage.getItem("TOURL")) {
+                // 如果去的地址等于缓存的地址
+                if (sessionStorage.getItem("TOURL") == to.path) {
+                    sessionStorage.setItem("TOURL", '')
+                    if (to.path == "/") {
+                        next("/group")
+                    }
+                    if (to.path == "/group" || to.path == "/home/homepage") {
+                        if (store.state.accessLevel == -1) {
+                            await store.dispatch("getUserInfo", router)
+                            await store.dispatch("getBrand")
+                            // await store.dispatch('getFact')
+                        }
+                    }
+                    await store.dispatch("getFloors")
+                    await store.dispatch("getBrand")
+                    next()
+                } else {
+                    next(sessionStorage.getItem("TOURL"))
+                }
+            } else {
+                if (to.path == "/") {
+                    next("/group")
+                }
+                if (to.path == "/group" || to.path == "/home/homepage") {
+                    if (store.state.accessLevel == -1) {
+                        await store.dispatch("getUserInfo", router)
+                        console.log('getUserInfo', 4)
+                        await store.dispatch("getBrand")
+                        // await store.dispatch('getFact')
+                    }
+                }
+                await store.dispatch("getFloors")
+                await store.dispatch("getBrand")
+                next()
+            }
 
 
-//         } else {
-//             redirectGetToken(to,from)
-//         }
-//     } else {
-//         next()
-//         return
-//     }
-// })
+        } else {
+            redirectGetToken(to,from)
+        }
+    } else {
+        next()
+        return
+    }
+})
 // 跳入路由后要对发送pvuv
 router.afterEach((to) => {
     let postParams = {

+ 1 - 1
src/views/analysis/GanttChart.vue

@@ -749,7 +749,7 @@ export default {
         .expand{
           transform: rotate(180deg);
         }
-      } 
+      }
     }
     .test-content {
       display: block;