Sfoglia il codice sorgente

去除自制 serverLog

Michael Wang 5 anni fa
parent
commit
3fc2ef724f

+ 38 - 11
src/components/FaceRecognition/FaceRecognition.vue

@@ -51,15 +51,16 @@ export default {
           this.lastSnapTime = Date.now();
           this.snapTimer();
         } else {
-          // this.serverLog(
-          //   "debug/S-002001",
-          //   "上次的抓拍未超过1分钟,本次抓拍指令取消"
-          // );
           window._hmt.push([
             "_trackEvent",
             "摄像头框",
-            "上次的抓拍未超过1分钟,本次抓拍指令取消",
+            "上次的抓拍未超过20秒,本次抓拍指令取消",
           ]);
+          this.logger({
+            page: "摄像头框",
+            action: "抓拍取消",
+            detail: "上次的抓拍未超过20秒,本次抓拍指令取消",
+          });
           this.decreaseSnapCount();
         }
         this.toggleSnapNow();
@@ -330,7 +331,6 @@ export default {
           });
           throw "定时抓拍照片大小异常";
         }
-        // this.serverLog("debug/S-004001", "抓拍照片的大小:" + captureBlob.size);
         const startTime = Date.now();
         const [captureFilePath, signIdentifier] = await this.uploadToServer(
           captureBlob
@@ -550,11 +550,16 @@ export default {
             throw "图片校验失败";
           }
         } catch (error) {
+          this.logger({
+            page: "摄像头框",
+            detail: "抓拍照片保存失败",
+            error: JSON.stringify(error),
+          });
           window._hmt.push([
             "_trackEvent",
             "摄像头框",
-            "抓拍照片保存失败--upyun",
-            error,
+            "抓拍照片保存失败",
+            JSON.stringify(error),
           ]);
           throw error;
         }
@@ -562,11 +567,15 @@ export default {
         // console.log(response);
         resultUrl = res.data.accessUrl;
         signIdentifier = res.data.signIdentifier;
-        // this.serverLog("debug/S-005001", "抓拍照片保存成功:");
+        this.logger({ page: "摄像头框", detail: "抓拍照片保存成功" });
         window._hmt.push(["_trackEvent", "摄像头框", "抓拍照片保存成功"]);
       } catch (e) {
         console.log(e);
-        // this.serverLog("debug/S-006001", "抓拍照片保存失败");
+        this.logger({
+          page: "摄像头框",
+          detail: "保存抓拍照片到服务器失败!",
+          error: JSON.stringify(e),
+        });
         window._hmt.push([
           "_trackEvent",
           "摄像头框",
@@ -627,7 +636,10 @@ export default {
                       cameraInfos = cameraInfos.replace(/\r\n/g, "");
                       cameraInfos = cameraInfos.replace(/\n/g, "");
                       console.log(cameraInfos);
-                      this.serverLog("debug/S-001001", cameraInfos);
+                      this.logger({
+                        page: "摄像头框",
+                        cameraInfos,
+                      });
                     }
                     if (cameraInfos.includes('""')) {
                       hasVirtualCamera = true;
@@ -640,6 +652,11 @@ export default {
                     }
                     resolve();
                   } catch (error) {
+                    this.logger({
+                      page: "摄像头框",
+                      type: "虚拟摄像头-读取摄像头列表失败",
+                      error: JSON.stringify(error),
+                    });
                     window._hmt.push([
                       "_trackEvent",
                       "摄像头框",
@@ -682,6 +699,11 @@ export default {
         try {
           await this.showSnapResult(fileName, examRecordDataId);
         } catch (error) {
+          this.logger({
+            page: "摄像头框",
+            action: "设置获取抓拍结果失败!",
+            error: JSON.stringify(error),
+          });
           this.$Message.error({
             content: "设置获取抓拍结果失败!",
             duration: 15,
@@ -690,6 +712,11 @@ export default {
         }
       } catch (e) {
         console.log(e);
+        this.logger({
+          page: "摄像头框",
+          action: "faceCompare失败",
+          error: e.response ? e.response.data.desc : e,
+        });
         window._hmt.push([
           "_trackEvent",
           "摄像头框",

+ 10 - 21
src/features/OnlineExam/Examing/ExamingHome.vue

@@ -288,7 +288,6 @@ export default {
                   cameraInfos = cameraInfos.replace(/\r\n/g, "");
                   cameraInfos = cameraInfos.replace(/\n/g, "");
                   console.log(cameraInfos);
-                  this.serverLog("debug/S-001001", cameraInfos);
                 }
                 resolve();
               } catch (error) {
@@ -432,9 +431,8 @@ export default {
         this.faceEnable = true;
 
         // setTimeout(() => {
-        //   this.serverLog("debug/S-002001", "进入考试后60秒内抓拍");
         //   this.toggleSnapNow(); // 开启抓拍才在进入考试时抓拍一张
-        // }, 60 * 1000); // 60后抓拍
+        // }, 60 * 1000); // 60秒后抓拍
 
         let initSnapshotTrialTimes = 0;
         this.initSnapInterval = setInterval(() => {
@@ -471,11 +469,6 @@ export default {
 
               this.logout("?LogoutReason=" + "摄像头没有正常启用-退出");
             } else {
-              this.serverLog(
-                "debug/S-002001",
-                "进入考试后60秒内抓拍-" +
-                  `(第${initSnapshotTrialTimes + 1}次尝试)`
-              );
               this.logger({
                 action: "答题页面",
                 detail:
@@ -490,21 +483,16 @@ export default {
         //       let initSnapshotTrialTimes = 0;
         // const initSnapshot = setTimeout(() => {
         //   if (this.exam || initSnapshotTrialTimes < 6) {
-        //     this.serverLog("debug/S-002001", "进入考试后60秒内抓拍");
         //     this.toggleSnapNow(); // 开启抓拍才在进入考试时抓拍一张
         //   } else {
         //     setTimeout(() => initSnapshot(), 5 * 1000);
         //   }
-        // }, 5 * 1000); // 60内秒钟后抓拍
+        // }, 5 * 1000);
 
         if (examProp.SNAPSHOT_INTERVAL) {
           const SNAPSHOT_INTERVAL = JSON.parse(examProp.SNAPSHOT_INTERVAL);
           // 考务设置抓拍间隔
           this.snapInterval = setInterval(() => {
-            // this.serverLog(
-            //   "debug/S-002001",
-            //   "根据抓拍间隔抓拍:抓拍间隔=" + SNAPSHOT_INTERVAL + "分钟"
-            // );
             this.toggleSnapNow();
           }, SNAPSHOT_INTERVAL * 60 * 1000);
         }
@@ -673,7 +661,10 @@ export default {
           if (!enoughTimeForFaceId) return;
 
           this.faceIdMsgTimeout = setTimeout(() => {
-            // this.serverLog("debug/S-002001", "活体检测前抓拍");
+            this.logger({
+              action: "答题页面",
+              detail: "活体检测前抓拍",
+            });
             this.toggleSnapNow();
             this.$Message.info({
               content: "30秒后开始指定动作检测",
@@ -682,7 +673,6 @@ export default {
             });
           }, faceVerifyMinute * 60 * 1000 - 30 * 1000); // 活体检测提醒
           this.faceIdDivTimeout = setTimeout(() => {
-            // this.serverLog("debug/S-003001", "准备弹出活体检测框");
             if (identificationOfLivingBodyScheme === "S1") {
               this.showFaceId = true;
             } else if (identificationOfLivingBodyScheme === "S2") {
@@ -713,6 +703,10 @@ export default {
       } else if (faceLiveResult.needNextVerify) {
         const initFaceLivenessResult = await this.initFaceLiveness();
         if (initFaceLivenessResult === false) {
+          this.logger({
+            action: "答题页面",
+            detail: "活检接口再次获取失败-退出",
+          });
           window._hmt.push([
             "_trackEvent",
             "答题页面",
@@ -769,10 +763,6 @@ export default {
               " |||| " +
               (((error.response || {}).data || {}).desc || ""),
           ]);
-          this.serverLog(
-            "debug/S-008001",
-            `提交答案失败 => 考试剩余时间:${this.remainTime / 1000}`
-          );
         }
       }
     },
@@ -827,7 +817,6 @@ export default {
       this.logger({ action: "正在交卷,请耐心等待..." });
       if (this.faceEnable) {
         this.logger({ action: "交卷前抓拍" });
-        this.serverLog("debug/S-002001", "交卷前抓拍");
         this.toggleSnapNow();
       }
       // 确保抓拍指令在交卷前执行,同时确保5秒间隔提交答案的指令执行了

+ 0 - 2
src/features/OnlineExam/Examing/FaceMotion/FaceMotion.vue

@@ -1047,11 +1047,9 @@ export default {
         // console.log(response);
         resultUrl = res.data.accessUrl;
         signIdentifier = res.data.signIdentifier;
-        // this.serverLog("debug/S-005001", "抓拍照片保存成功:");
         window._hmt.push(["_trackEvent", "摄像头框", "抓拍照片保存成功"]);
       } catch (e) {
         console.log(e);
-        // this.serverLog("debug/S-006001", "抓拍照片保存失败");
         window._hmt.push([
           "_trackEvent",
           "摄像头框",

+ 3 - 10
src/features/OnlineExam/Examing/RemainTime.vue

@@ -108,23 +108,16 @@ export default {
             action: "发出心跳",
             error: "心跳失败",
             detail: "失败-会话过期",
+            extraDetail: `考试剩余时间:${this.remainTime / 1000}`,
           });
-          this.serverLog(
-            "debug/S-008002",
-            `心跳失败-会话过期 => 考试剩余时间:${this.remainTime / 1000}`
-          );
         } else {
           window._hmt.push(["_trackEvent", "答题页面", "心跳", "失败"]);
           this.logger({
             action: "发出心跳",
             error: "心跳失败",
-            detail1: `考试剩余时间:${this.remainTime / 1000}`,
-            detail2: JSON.stringify(error),
+            detail: `考试剩余时间:${this.remainTime / 1000}`,
+            extraDetail: JSON.stringify(error),
           });
-          this.serverLog(
-            "debug/S-008003",
-            `心跳失败 => 考试剩余时间:${this.remainTime / 1000} => ${error}`
-          );
         }
         this.heartbeatErrorNum++;
         if (this.heartbeatErrorNum >= 10) {

+ 0 - 15
src/mixins/mixins.js

@@ -18,21 +18,6 @@ Vue.mixin({
     logger(logs) {
       createLog(logs);
     },
-    async serverLog(level, logText) {
-      try {
-        await this.$http.post(
-          "/api/ecs_core/log/studentClient/" + level,
-          logText,
-          {
-            headers: {
-              "Content-Type": "text/plain",
-            },
-          }
-        );
-      } catch (error) {
-        console.log(error);
-      }
-    },
     async checkExamInProgress() {
       try {
         // 断点续考