Browse Source

更新判断

lex-xin 3 years ago
parent
commit
dfc5303a5b
1 changed files with 8 additions and 3 deletions
  1. 8 3
      src/App.vue

+ 8 - 3
src/App.vue

@@ -18,10 +18,15 @@ export default {
   async created() {
     try {
       let Authorization = this.getQueryVariable('Authorization')
-      Authorization = Authorization ? Authorization.split('+')[1] : null
+      if(window.location.hash.indexOf("+") >= 0) {
+        Authorization = Authorization ? Authorization.split('+')[1] : null
+        Authorization = ('bearer ' + Authorization)
+      } else {
+        Authorization = decodeURI(Authorization)
+      }
       if (Authorization) {
-        localStorage.setItem("Authorization", ('bearer ' + Authorization));
-        localStorage.setItem("userInfo", ('bearer ' + Authorization));
+        localStorage.setItem("Authorization", Authorization);
+        localStorage.setItem("userInfo", Authorization);
       }
       const auth = localStorage.getItem("Authorization");
       const userInfo = localStorage.getItem("userInfo");