Pārlūkot izejas kodu

优化导入算法的上传

zhangliang2 3 gadi atpakaļ
vecāks
revīzija
6930249945
1 mainītis faili ar 18 papildinājumiem un 5 dzēšanām
  1. 18 5
      src/views/algorithmsLibrary/exportAlgorithms.vue

+ 18 - 5
src/views/algorithmsLibrary/exportAlgorithms.vue

@@ -118,6 +118,7 @@ export default {
             timer: null, // 用来接收进度条的定时器
             percentage: 0, // 进度条数据
             customColor: "", // 进度条颜色
+            step: 0, // 为了优化进度条
         };
     },
 
@@ -127,7 +128,7 @@ export default {
 
     methods: {
         attachmentChange(obj) {
-            // console.log(obj);
+            console.log(obj);
             if (obj.length > 0) {
                 this.form.minioPath = obj[0].fileName;
                 this.$refs.form.clearValidate("minioPath");
@@ -171,11 +172,21 @@ export default {
                 },
             }).then((res) => {
                 if (res.code == 200 && res.info) {
-                    console.log(res.info);
+                    // console.log(res.info);
 
                     if (this.percentage >= res.info * 100) {
-                        if (this.percentage < 99) {
-                            ++this.percentage;
+                        if (+res.info === 0) {
+                            this.step++;
+                            // 如果一直为0,进度显示每3次加一
+                            if (this.step % 3 === 0) {
+                                if (this.percentage < 99) {
+                                    ++this.percentage;
+                                }
+                            }
+                        } else {
+                            if (this.percentage < 99) {
+                                ++this.percentage;
+                            }
                         }
                     } else {
                         this.percentage = res.info * 100;
@@ -191,6 +202,7 @@ export default {
                         clearInterval(this.timer);
                         this.timer = null;
                         this.percentage = 0;
+                        this.step = 0;
                         this.objectPath = this.$getObjectPathByRandom();
                     }
                 } else {
@@ -210,6 +222,7 @@ export default {
             clearInterval(this.timer);
             this.timer = null;
             this.percentage = 0;
+            this.step = 0;
             this.objectPath = this.$getObjectPathByRandom();
         },
     },
@@ -242,7 +255,7 @@ export default {
     beforeDestroy() {
         clearInterval(this.timer);
         this.timer = null;
-    }
+    },
 };
 </script>