Browse Source

上次路由的保存

zhulizhen1111 4 years ago
parent
commit
c79d1ac2a5
2 changed files with 14 additions and 0 deletions
  1. 2 0
      src/router/index.js
  2. 12 0
      src/views/strategy/index.vue

+ 2 - 0
src/router/index.js

@@ -82,6 +82,8 @@ router.beforeEach(async (to, from, next) => {
     let ssoServer = 'http://sso.sagacloud.cn'
     let redirectUrl = window.location.protocol + '//' + window.location.host + '/strategy'
     window.location.href = `${ssoServer}/login?redirectUrl=${redirectUrl}`
+    let lastRoute = { path: to.path, params: to.params, query: to.query }
+    sessionStorage.setItem('lastRoute',JSON.stringify(lastRoute))
   }
 })
 

+ 12 - 0
src/views/strategy/index.vue

@@ -138,6 +138,18 @@ export default {
         // },1500)
         // this.getQuickData();
         this.getChiller()
+    },
+    created(){
+        if(sessionStorage.getItem('lastRoute')){
+             let lastRoute = JSON.parse(sessionStorage.getItem('lastRoute'))
+            let lastPath = lastRoute.path.split('/')[1]
+            if(lastPath){
+                this.$router.replace(`/${lastPath}`)
+            }else{
+                this.$router.replace('/strategy')
+            }
+        }
+       
     }
 }
 </script>