Browse Source

退出后不再下载

Michael Wang 3 years ago
parent
commit
cb58c43447
1 changed files with 6 additions and 1 deletions
  1. 6 1
      src/features/ImageDownload/ImageDownload.vue

+ 6 - 1
src/features/ImageDownload/ImageDownload.vue

@@ -16,7 +16,7 @@
 
 <script setup lang="ts">
 import { store } from "@/store";
-import { onMounted, ref, watch } from "vue";
+import { onMounted, onUnmounted, ref, watch } from "vue";
 import { Modal } from "ant-design-vue";
 import { useRouter } from "vue-router";
 const router = useRouter();
@@ -121,6 +121,7 @@ onMounted(async () => {
 
         for (const student of students) {
           for (const sheetUrl of student.sheetUrls) {
+            if (stopSignal) return;
             try {
               const index = student.sheetUrls.indexOf(sheetUrl);
               student.index = index + 1;
@@ -210,6 +211,7 @@ async function processPackage() {
     const p = array[i];
     p.examId = store.env.examId;
     for (let i = 0; i < p.urls.length; i++) {
+      if (stopSignal) return;
       try {
         const index = i + 1;
         p.index = index;
@@ -245,4 +247,7 @@ async function processPackage() {
     finishedCount.value += 1;
   }
 }
+
+let stopSignal = false;
+onUnmounted(() => (stopSignal = true));
 </script>