Browse Source

更新判断

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

+ 28 - 29
src/App.vue

@@ -18,37 +18,36 @@ export default {
   async created() {
     const whiteList = ["/order"];
     const routePath = this.$route.path;
-    if(whiteList.includes(routePath)) {
-      return;
-    }
-    try {
-      let Authorization = this.getQueryVariable('Authorization') || null;
-      if(window.location.hash.indexOf("+") >= 0) {
-        Authorization = Authorization ? Authorization.split('+')[1] : null
-        Authorization = ('bearer ' + Authorization)
-      } else {
-        Authorization = decodeURI(Authorization)
-      }
-      if (Authorization && Authorization != 'null') {
-        localStorage.setItem("Authorization", Authorization);
-        localStorage.setItem("userInfo", Authorization);
-      }
-      const auth = localStorage.getItem("Authorization") || "";
-      const userInfo = localStorage.getItem("userInfo") || "";
-      if (userInfo || auth) {
-        await queryTeacherInfo().then((res) => {
-          const result = res.data || null;
-          const tenantId = result.data.tenantId || 0;
-          sessionStorage.setItem("tenantId", tenantId);
-        });
+    if (!whiteList.includes(routePath)) {
+      try {
+        let Authorization = this.getQueryVariable("Authorization") || null;
+        if (window.location.hash.indexOf("+") >= 0) {
+          Authorization = Authorization ? Authorization.split("+")[1] : null;
+          Authorization = "bearer " + Authorization;
+        } else {
+          Authorization = decodeURI(Authorization);
+        }
+        if (Authorization && Authorization != "null") {
+          localStorage.setItem("Authorization", Authorization);
+          localStorage.setItem("userInfo", Authorization);
+        }
+        const auth = localStorage.getItem("Authorization") || "";
+        const userInfo = localStorage.getItem("userInfo") || "";
+        if (userInfo || auth) {
+          await queryTeacherInfo().then((res) => {
+            const result = res.data || null;
+            const tenantId = result.data.tenantId || 0;
+            sessionStorage.setItem("tenantId", tenantId);
+          });
+        }
+      } catch (e) {
+        console.log(e);
       }
-    } catch(e) {
-      console.log(e)
     }
   },
   async mounted() {
-    if(document.querySelector('#m_loading')) {
-      document.querySelector('#m_loading').remove()
+    if (document.querySelector("#m_loading")) {
+      document.querySelector("#m_loading").remove();
     }
   },
   methods: {
@@ -56,7 +55,7 @@ export default {
       if (window.location.hash.indexOf("?") < 0) {
         return null;
       }
-      let query = window.location.hash.split("?")[1]
+      let query = window.location.hash.split("?")[1];
       let vars = query.split("&");
       for (let i = 0; i < vars.length; i++) {
         let pair = vars[i].split("=");
@@ -64,7 +63,7 @@ export default {
           return pair[1];
         }
       }
-      return (false);
+      return false;
     },
   },
 };