Prechádzať zdrojové kódy

fix 离线考试上传文件时,文件后缀名与内容不符的情况

fix 上传错误提示

fix 上传文件的提示内容
Michael Wang 6 rokov pred
rodič
commit
d9c97eac40

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

@@ -13,7 +13,7 @@
       style="position: absolute; width: 400px; text-align: center; margin-top: -50px; color: #232323;"
       style="position: absolute; width: 400px; text-align: center; margin-top: -50px; color: #232323;"
     >
     >
       <button
       <button
-        :class="['verify-button', disableSnap && 'disable-verify-button']"
+        :class="['verify-button', !disableSnap && 'disable-verify-button']"
         @click="snap"
         @click="snap"
         :disabled="disableSnap"
         :disabled="disableSnap"
       >{{msg}}</button>
       >{{msg}}</button>
@@ -354,11 +354,12 @@ export default {
 }
 }
 
 
 .disable-verify-button {
 .disable-verify-button {
-  background-color: #ffceff;
+  background-color: #f7f7f7;
+  color: #c5c8ce;
 }
 }
 
 
 .disable-verify-button:hover {
 .disable-verify-button:hover {
-  color: black;
   cursor: not-allowed;
   cursor: not-allowed;
+  color: #c5c8ce;
 }
 }
 </style>
 </style>

+ 28 - 5
src/features/OfflineExam/OfflineExamUpload.vue

@@ -1,6 +1,7 @@
 <template>
 <template>
   <div>
   <div>
     <Upload
     <Upload
+      ref="uploadComp"
       :headers="headers"
       :headers="headers"
       :data="{fileType: fileType}"
       :data="{fileType: fileType}"
       :before-upload="handleBeforeUpload"
       :before-upload="handleBeforeUpload"
@@ -83,10 +84,32 @@ export default {
             hex: hex
             hex: hex
           });
           });
 
 
-          if (
-            ["application/zip", "application/pdf"].includes(getMimetype(hex))
-          ) {
-            resolve();
+          if (["application/pdf"].includes(getMimetype(hex))) {
+            if (!file.name.endsWith(".pdf")) {
+              this.loadingStatus = false;
+              this.$Notice.warning({
+                title: "文件内容与文件的后缀不一致"
+                // desc: file.name + " 文件是pdf文档,但文件名后缀不是.pdf!"
+              });
+              this.file = null;
+              reject("文件内容与文件的后缀不一致,请确认文件是pdf文档!");
+            } else {
+              resolve();
+            }
+          } else if (["application/zip"].includes(getMimetype(hex))) {
+            if (!file.name.endsWith(".zip")) {
+              this.loadingStatus = false;
+              // this.$refs.uploadComp.fileList.splice(0);
+              // this.$refs.uploadComp.fileList = [];
+              this.$Notice.warning({
+                title: "文件内容与文件的后缀不一致"
+                // desc: file.name + " 文件是zip压缩包,但文件名后缀不是.zip!"
+              });
+              this.file = null;
+              reject("文件内容与文件的后缀不一致,请确认文件是zip压缩包!");
+            } else {
+              resolve();
+            }
           } else {
           } else {
             console.log("binary file type check: not zip or pdf");
             console.log("binary file type check: not zip or pdf");
             window._hmt.push([
             window._hmt.push([
@@ -101,7 +124,7 @@ export default {
             });
             });
             this.file = null;
             this.file = null;
             this.loadingStatus = false;
             this.loadingStatus = false;
-            reject();
+            reject("作答文件损坏");
           }
           }
         }
         }
       };
       };