瀏覽代碼

cleanup code

Michael Wang 5 年之前
父節點
當前提交
2b02fd511e

+ 0 - 3
src/components/FaceRecognition/FaceRecognition.vue

@@ -224,7 +224,6 @@ export default {
           examRecordDataId
         );
       } catch (error) {
-        // FIXME: more processing
         console.log("定时抓拍流程失败", error);
         window._hmt.push([
           "_trackEvent",
@@ -294,7 +293,6 @@ export default {
         this.msg = "人脸比对中...";
         await this.faceCompareSync(captureFilePath, signIdentifier);
       } catch (error) {
-        // FIXME: more processing
         console.log("同步照片比对流程失败");
         throw error;
       } finally {
@@ -440,7 +438,6 @@ export default {
             encodeURIComponent(captureFilePath)
         );
 
-        // TODO: 识别成功、失败的通知或跳转
         this.$emit("on-recognize-result", {
           error: null,
           pass: res.data.isPass,

+ 7 - 0
src/features/Login/Login.vue

@@ -307,6 +307,13 @@ export default {
   },
   async created() {
     if (navigator.connection) {
+      console.log(
+        "_trackEvent",
+        "登录页面",
+        `当前网速: ${Number(navigator.connection.downlink).toPrecision(
+          1
+        )}Mib; 网络延迟: ${Number(navigator.connection.rtt).toPrecision(1)}ms`
+      );
       window._hmt.push([
         "_trackEvent",
         "登录页面",

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

@@ -649,12 +649,6 @@ export default {
           this.tipHandler =
             this.tipHandler ||
             throttle(message => {
-              // this.$message({
-              //   type: "warning",
-              //   message,
-              //   duration: 1000,
-              //   offset: 300,
-              // });
               this.$Message.warning({ content: message, duration: 1 });
             }, 1500);
           this.tipHandler(message);
@@ -715,12 +709,6 @@ export default {
                 (result.expressions.happy < 0.5 && this.currentStep.happy) ||
                 (result.expressions.neutral < 0.5 && !this.currentStep.happy)
               ) {
-                // this.$message({
-                //   type: "warning",
-                //   message: this.currentStep.happy ? "请保持微笑" : "请保持严肃",
-                //   duration: 1000,
-                //   offset: 300,
-                // });
                 this.$Message.warning({
                   content: this.currentStep.happy ? "请保持微笑" : "请保持严肃",
                   duration: 1,
@@ -738,12 +726,6 @@ export default {
           this.behavingStartDate = null;
 
           if (!this.moveFaceMessage) {
-            // this.moveFaceMessage = this.$message({
-            //   type: "info",
-            //   message: "请将您的脸部移向笑脸所在的区块",
-            //   duration: 3000,
-            //   offset: 300,
-            // });
             this.moveFaceMessage = this.$Message.info({
               content: "请将您的脸部移向笑脸所在的区块",
               duration: 1,
@@ -762,12 +744,6 @@ export default {
             if (this.happyFailedTimes % 2) {
               if (Date.now() - (this.showExpresionTipDate || 0) > 1500) {
                 this.showExpresionTipDate = Date.now();
-                // this.$message({
-                //   type: "warning",
-                //   message: this.currentStep.happy ? "请保持微笑" : "请保持严肃",
-                //   duration: 1000,
-                //   offset: 300,
-                // });
                 this.$Message.warning({
                   content: this.currentStep.happy ? "请保持微笑" : "请保持严肃",
                   duration: 1,
@@ -966,9 +942,6 @@ export default {
       try {
         const buffer = await blobToArray(captureBlob);
 
-        // console.log(buffer);
-        // var view1 = new Uint8Array(buffer);
-        // console.log(buffer[0], buffer[1], buffer[429721]);
         const fileMd5 = MD5(buffer);
         console.log(fileMd5);
 
@@ -979,15 +952,6 @@ export default {
           "/api/ecs_oe_student/examControl/getCapturePhotoUpYunSign?" + params
         );
 
-        // console.log(res);
-
-        // let myHeaders = new Headers();
-        // for (let [k, v] of Object.entries(res.data.headers)) {
-        //   // console.log(k, v);
-        //   if (k.includes("tion") || k.includes("Date") || k.includes("MD5")) {
-        //     if (k === "Date") k = "x-date";
-        //     myHeaders.append(k, v);
-        //   }
         let myFormData = new FormData();
         for (let [k, v] of Object.entries(res.data.formParams)) {
           myFormData.append(k, v);
@@ -1043,16 +1007,9 @@ export default {
             encodeURIComponent(captureFilePath)
         );
 
-        // // TODO: 识别成功、失败的通知或跳转
-        // this.$emit("on-recognize-result", {
-        //   error: null,
-        //   pass: res.data.isPass,
-        //   stranger: res.data.isStranger,
-        // });
         return res.data;
       } catch (e) {
         console.log(e);
-        // this.$Message.error(e.message);
         throw "同步照片比较失败!";
       }
     },

+ 0 - 111
src/features/OnlineExam/Examing/QuestionBody.vue

@@ -73,63 +73,18 @@ export default {
     },
   },
   mounted() {
-    // console.log(
-    //   "Mounted: " + this.examQuestion.questionId + " : " + this.questionBody
-    // );
     this.parseQuestion();
   },
-  // beforeDestroy() {
-  //   console.log(
-  //     "Destroy: " + this.examQuestion.questionId + " : " + this.questionBody
-  //   );
-  // },
-  // updated() {
-  //   if (this.questionBody.includes("question-audio")) {
-  //     console.log(this.questionBody);
-  //     this.bindAudioPlay();
-  //   }
-  // },
   methods: {
     ...mapMutations(["updateExamQuestion", "updateQuestionAudioPlayTimes"]),
     async parseQuestion() {
       let question = {};
       if (this.questionBody.includes("question-audio")) {
-        // let audioArray = this.questionBody.match(/<a.*?question-audio.*?\/a>/g);
-        // if (!this.examQuestion.audioPlayTimes) {
-        //   // 初始化音频播放次数
-        //   this.audioPlayTimes = [];
-        // } else {
-        //   this.audioPlayTimes = JSON.parse(this.examQuestion.audioPlayTimes);
-        // }
         question.text = this.questionBody.replace(
           /<a.*?question-audio.*?\/a>/g,
           ""
         );
         // 测试 v-html中含有directive是否生效。结论:不生效
-        // question.text += "<span v-html='<text>abc</text>'>empty</span>";
-        // audioArray = audioArray.map((v, i) => {
-        //   const remainTimes =
-        //     this.examQuestion.limitedPlayTimes -
-        //     this.examQuestion.audioPlayTimes[i];
-        //   if (remainTimes <= 0) {
-        //     v = v.replace("<a", "<a disabled"); // disabled不生效,仅仅起标明作用
-        //     v = v.replace(/url=/g, "");
-        //   }
-        //   return `${v}<span>(剩余播放次数:${remainTimes})</span><br/>`;
-        // });
-        // question.audio = audioArray
-        //   .join("")
-        //   .replace(/<a/g, "<audio controls controlsList='nodownload'")
-        //   .replace(/url=/g, "src=")
-        //   .replace(/a>/g, "audio>");
-
-        // console.log(this.questionBody);
-        // console.log(this.questionBody.match(/url="[^"]*"/g));
-        // question.audio = this.questionBody
-        //   .match(/url="[^"]*"/g)
-        //   .map(v => v.replace("url="));
-
-        // /question-audio.*?url="[^"]*"/.exec(this.questionBody)
 
         question.audio = [];
         let re;
@@ -138,69 +93,14 @@ export default {
         }
         let array1;
         while ((array1 = re.exec(this.questionBody)) !== null) {
-          // console.log(`Found ${array1[0]}. Next starts at ${re.lastIndex}.`);
-          // console.log(array1[1]);
           question.audio.push({ name: array1[1], src: array1[2] });
-          // console.log(question.audio);
-          // expected output: "Found foo. Next starts at 9."
-          // expected output: "Found foo. Next starts at 19."
         }
-
-        // setTimeout(this.bindAudioPlay.bind(this), 1000);
       } else {
         question.text = this.questionBody;
         question.audio = [];
       }
       this.questionDetail = question;
-
-      // TODO: web audio get data progress, then construct audio element
-      // for (let { src, name } of this.questionDetail.audio) {
-      // var xmlhttp = new XMLHttpRequest(),
-      //   method = "GET",
-      //   url = src;
-
-      // xmlhttp.open(method, url, true);
-      // xmlhttp.onprogress = function(e) {
-      //   //do something
-      //   console.log(e);
-      // };
-      // xmlhttp.send();
-      //   fetch(src, { method: "HEAD", mode: "cors" }).then(res => {
-      //     console.log(res);
-      //     console.log([...res.headers.keys()]);
-      //   });
-      // }
     },
-    // bindAudioPlay() {
-    //   const audios = document.getElementsByTagName("audio");
-    //   if (audios.length === 0) {
-    //     // setTimeout(this.bindAudioPlay.bind(this), 1000);
-    //     return;
-    //   }
-
-    //   [...audios].forEach((audio, index) => {
-    //     console.log("bind audio: order:" + this.examQuestion.order);
-    //     const order = this.examQuestion.order;
-    //     const limitedPlayTimes = this.examQuestion.limitedPlayTimes;
-    //     let audioPlayTimes = this.examQuestion.audioPlayTimes;
-
-    //     audio.addEventListener("play", () => {
-    //       console.log("开始播放");
-    //       if (limitedPlayTimes - audioPlayTimes <= 0) {
-    //         console.log("无剩余播放次数");
-    //       }
-    //       audioPlayTimes[index] = audioPlayTimes[index] + 1;
-    //       this.updateExamQuestion({
-    //         order: order,
-    //         audioPlayTimes: audioPlayTimes
-    //       });
-    //     });
-    //     audio.addEventListener("ended", () => {
-    //       console.log("结束播放");
-    //       this.parseQuestion(); // 不会死循环,因为这个是音频播放触发的
-    //     });
-    //   });
-    // },
     audioClicked(index, $event) {
       if ($event.target.paused === false) {
         // 正在播放中,不能暂停
@@ -236,14 +136,6 @@ export default {
       s.add(name);
       this.audioInPlay = s;
 
-      // var audio = new Audio($event.target.src);
-      // audio.play();
-
-      // if (theAudio) {
-      //   theAudio.times = playedTimes + 1;
-      // } else {
-      //   this.audioPlayTimes.push({ name: name, times: 1 });
-      // }
       if ($event.target.paused === false) {
         // 正在播放中
         this.updateQuestionAudioPlayTimes(name);
@@ -266,9 +158,6 @@ export default {
   display: flex;
   align-items: center;
 }
-/* .question-body audio {
-  width: 180px;
-} */
 .question-body audio::-webkit-media-controls-timeline,
 .question-body audio::-webkit-media-controls-timeline-container {
   display: none;

+ 1 - 10
src/features/OnlineExam/OnlineExamFaceCheckModal.vue

@@ -21,14 +21,6 @@
     <div
       style="display: grid; grid-template-columns: 200px 400px 1fr; grid-gap: 5px; position: relative"
     >
-      <!-- TODO: 显示子组件的message -->
-      <!-- <div style="position: absolute; top: -16px; left: 0; width: 100%; height: 50px; 
-                  background-color: #eee; opacity: 0.8; display: grid; ">
-        <div
-          class="qm-title-text"
-          style="width: 100%; text-algin: center; "
-        >msg</div>
-      </div> -->
       <div class="avatar" :style="{ backgroundImage: `url('${userPhoto}')` }">
         <!-- <img :src="userPhoto" width="200px" height="300px" alt="底照" /> -->
         <div
@@ -36,8 +28,7 @@
           style="text-align: center; margin-top: 260px; color: white;"
         >
           <span
-            style="background-color: rgba(0, 0, 0, 0.5); display: inline-block;
-                       padding: 6px 16px; border-radius: 6px;"
+            style="background-color: rgba(0, 0, 0, 0.5); display: inline-block; padding: 6px 16px; border-radius: 6px;"
           >
             {{ userPhoto ? "我的底照" : "无底照" }}
           </span>

+ 1 - 1
src/utils/axios.js

@@ -205,7 +205,7 @@ qmInstance.get = cachingGet(qmInstance.get, [
 loadProgressBar(qmInstance);
 
 // const upyunInstance = axios.create({});
-// // FIXME: axios bug. wait 0.19 release. https://github.com/axios/axios/issues/385
+// FIXME: axios bug. wait 0.19 release. https://github.com/axios/axios/issues/385
 // upyunInstance.defaults.headers.common = {};
 // // upyunInstance.defaults.headers.common["Authorization"] = UPYUN_HEADER_AUTH;