Procházet zdrojové kódy

一个小bug修复

刘洋 před 11 měsíci
rodič
revize
6715ee8d50
1 změnil soubory, kde provedl 16 přidání a 14 odebrání
  1. 16 14
      src/features/ImageDownload/ImageDownload.vue

+ 16 - 14
src/features/ImageDownload/ImageDownload.vue

@@ -26,6 +26,15 @@ import mustache from "mustache";
 
 
 let statisticTime = 0;
 let statisticTime = 0;
 
 
+function openSuccessDialog() {
+  const modal = Modal.success({});
+  modal.update({
+    title: "图片下载完成",
+    content: "完成",
+    onOk: () => router.back(),
+  });
+}
+
 async function getImageDim(
 async function getImageDim(
   blob: Blob
   blob: Blob
 ): Promise<[width: number, height: number]> {
 ): Promise<[width: number, height: number]> {
@@ -237,12 +246,7 @@ const studentHandler = async (student: any, urls: any) => {
           Date.now() - statisticTime
           Date.now() - statisticTime
         }ms`
         }ms`
       );
       );
-      const modal = Modal.success({});
-      modal.update({
-        title: "图片下载完成",
-        content: "完成",
-        onOk: () => router.back(),
-      });
+      openSuccessDialog();
     }
     }
     if (
     if (
       resultImgList.length === sheetUrlsLength &&
       resultImgList.length === sheetUrlsLength &&
@@ -303,6 +307,9 @@ onMounted(async () => {
       });
       });
       totalCount.value = res.data;
       totalCount.value = res.data;
       console.log(`一共${totalCount.value}个考生`);
       console.log(`一共${totalCount.value}个考生`);
+      if (totalCount.value == 0) {
+        openSuccessDialog();
+      }
       // let totalImageDownloadTime = 0;
       // let totalImageDownloadTime = 0;
       statisticTime = Date.now();
       statisticTime = Date.now();
       for (
       for (
@@ -350,12 +357,12 @@ onMounted(async () => {
     //   content: "完成",
     //   content: "完成",
     //   onOk: () => router.back(),
     //   onOk: () => router.back(),
     // });
     // });
-  } catch (error) {
+  } catch (error: any) {
     const modal = Modal.error({});
     const modal = Modal.error({});
     console.log(error);
     console.log(error);
     modal.update({
     modal.update({
       title: "图片下载出错",
       title: "图片下载出错",
-      content: error.message || error,
+      content: error?.message || error,
       onOk: () => router.back(),
       onOk: () => router.back(),
     });
     });
   }
   }
@@ -405,12 +412,7 @@ async function processPackage() {
     }
     }
     finishedCount.value += 1;
     finishedCount.value += 1;
     if (finishedCount.value == totalCount.value) {
     if (finishedCount.value == totalCount.value) {
-      const modal = Modal.success({});
-      modal.update({
-        title: "图片下载完成",
-        content: "完成",
-        onOk: () => router.back(),
-      });
+      openSuccessDialog();
     }
     }
   }
   }
 }
 }