Преглед на файлове

取验证码即发resource请求;网络失败的请求仅记本机日志

Michael Wang преди 5 години
родител
ревизия
61a973e887
променени са 3 файла, в които са добавени 25 реда и са изтрити 11 реда
  1. 13 5
      src/features/Login/Login.vue
  2. 4 0
      src/features/Login/VerifyCode.vue
  3. 8 6
      src/utils/monitors.js

+ 13 - 5
src/features/Login/Login.vue

@@ -192,7 +192,7 @@ export default {
         accountValue: "",
         password: "",
         verifyCode: "",
-        uuid: "",
+        tid: "",
         // result: "",
       },
       loginFormRule: {
@@ -213,7 +213,7 @@ export default {
         verifyCode: [
           {
             required: true,
-            message: "请填写验证码",
+            message: "请填写计算结果",
             trigger: "blur",
             type: "number",
           },
@@ -304,6 +304,14 @@ export default {
       );
     },
   },
+  watch: {
+    "loginForm.tid": function(val) {
+      logNewVersion(val);
+    },
+    // "loginForm.accountValue": function(val) {
+    //   console.log(val);
+    // },
+  },
   async mounted() {
     // this.testServiceWorker();
 
@@ -668,7 +676,7 @@ export default {
       let myHeaders = new Headers();
       myHeaders.append("Content-Type", "application/javascript");
       myHeaders.append("Cache-Control", "no-cache");
-      logNewVersion(this.loginForm.uuid);
+      // logNewVersion(this.loginForm.tid);
       const response = await fetch(
         document.scripts[document.scripts.length - 1].src + "?x" + Date.now(),
         {
@@ -677,7 +685,7 @@ export default {
         }
       );
       // 给后台更多时间去处理 resource/uuid.js 的请求
-      await new Promise(resolve => setTimeout(() => resolve(), 900));
+      await new Promise(resolve => setTimeout(() => resolve(), 1500));
       if (!response.ok || this.newVersionAvailable) {
         if (
           response.ok &&
@@ -1094,7 +1102,7 @@ export default {
     },
     calcVerify({ uuid, verifyCode }) {
       // console.log(uuid, verifyCode);
-      this.loginForm.uuid = uuid;
+      this.loginForm.tid = uuid;
       this.loginForm.verifyCode = verifyCode;
     },
   },

+ 4 - 0
src/features/Login/VerifyCode.vue

@@ -107,6 +107,10 @@ export default {
       // console.log(res);
       this.uuid = res.data.slice(0, 32);
       this.base64 = "data:image/jpeg;base64," + res.data.slice(32);
+      this.$emit("calcVerify", {
+        uuid: this.uuid,
+        verifyCode: this.result,
+      });
     },
     notify() {
       const p = window.parseInt(this.result);

+ 8 - 6
src/utils/monitors.js

@@ -82,12 +82,14 @@ window.addEventListener("unhandledrejection", function(event) {
   //     }
   //   }
   // );
-  createLog({
-    action: "unhandledrejection错误",
-    page: window.location.pathname,
-    reason: event.reason,
-    message: event.reason ? event.reason.message : "",
-  });
+  console.log("unhandledrejection event", event, event.reason);
+  // 会造成死循环,logger.log 在网络异常的情况下,会有unhandledrejection
+  // createLog({
+  //   action: "unhandledrejection错误",
+  //   page: window.location.pathname,
+  //   reason: event.reason,
+  //   message: event.reason ? event.reason.message : "",
+  // });
   if (
     event.reason &&
     event.reason.message &&