Explorar o código

ip访问时退出登录code丢失问题

zhangjie %!s(int64=2) %!d(string=hai) anos
pai
achega
39d8695950
Modificáronse 6 ficheiros con 24 adicións e 11 borrados
  1. 2 1
      src/constants/app.js
  2. 2 2
      src/main.js
  3. 1 5
      src/modules/login/views/Login.vue
  4. 6 1
      src/plugins/axios.js
  5. 7 1
      src/router.js
  6. 6 1
      src/views/Home.vue

+ 2 - 1
src/constants/app.js

@@ -5,7 +5,7 @@ export const APP_TITLE = "试卷电子化";
 
 // domain
 let domain;
-if (process.env.VUE_APP_SELF_DEFINE_DOMAIN === "true") {
+if (process.env.VUE_APP_SELF_DEFINE_DOMAIN === "true1") {
   domain = window.localStorage.getItem("domain_in_url");
 }
 if (!domain) {
@@ -13,6 +13,7 @@ if (!domain) {
   const hostname = window.location.hostname;
   if (ipFormat.test(hostname)) {
     domain = parseHrefParam(window.location.href, "code");
+    window.sessionStorage.setItem("ipDomainCode", domain);
   } else {
     domain = hostname.split(".")[0];
   }

+ 2 - 2
src/main.js

@@ -8,7 +8,7 @@ import "./plugins/keepAlive";
 import "./plugins/filters";
 
 // https://github.com/RobinCK/vue-ls
-import VueLocalStorage from "vue-ls";
+import VueStorage from "vue-ls";
 import ElementUI from "element-ui";
 import "cropperjs/dist/cropper.min.css";
 import "element-ui/lib/theme-chalk/index.css";
@@ -16,7 +16,7 @@ import "./assets/styles/index.scss";
 
 Vue.use(ElementUI, { size: "small" });
 
-Vue.use(VueLocalStorage, { storage: "session" });
+Vue.use(VueStorage, { namespace: "vs_", storage: "session" });
 Vue.use(globalVuePlugins);
 
 Vue.prototype.GLOBAL = GLOBAL;

+ 1 - 5
src/modules/login/views/Login.vue

@@ -223,11 +223,7 @@ export default {
       this.$ls.set("token", data.accessToken, this.GLOBAL.authTimeout);
 
       // 强制修改密码和绑定手机号
-      if (
-        data.userLoginCheckResult &&
-        (!data.userLoginCheckResult.pwdCount ||
-          !data.userLoginCheckResult.mobileNumber)
-      ) {
+      if (data.userLoginCheckResult && !data.userLoginCheckResult.pwdCount) {
         this.userInfo = {
           ...this.loginModel,
           ...data.userLoginCheckResult

+ 6 - 1
src/plugins/axios.js

@@ -176,7 +176,12 @@ const errorDataCallback = response => {
         }
 
         Vue.ls.clear();
-        router.push({ name: "Login" });
+        const ipDomainCode = window.sessionStorage.getItem("ipDomainCode");
+        if (ipDomainCode) {
+          router.push({ name: "Login", query: { code: ipDomainCode } });
+        } else {
+          router.push({ name: "Login" });
+        }
       }
     });
   } else {

+ 7 - 1
src/router.js

@@ -75,7 +75,13 @@ router.beforeEach((to, from, next) => {
     }
 
     Vue.ls.clear();
-    next({ name: "Login" });
+    const ipDomainCode = window.sessionStorage.getItem("ipDomainCode");
+    if (ipDomainCode) {
+      next({ name: "Login", query: { code: ipDomainCode } });
+    } else {
+      next({ name: "Login" });
+    }
+
     return;
   }
 

+ 6 - 1
src/views/Home.vue

@@ -351,7 +351,12 @@ export default {
       }
 
       this.$ls.clear();
-      this.$router.push({ name: "Login" });
+      const ipDomainCode = window.sessionStorage.getItem("ipDomainCode");
+      if (ipDomainCode) {
+        this.$router.push({ name: "Login", query: { code: ipDomainCode } });
+      } else {
+        this.$router.push({ name: "Login" });
+      }
     },
     toSelectSchool() {
       if (this.IS_SUPER_ADMIN) this.$router.push({ name: "SelectSchool" });