Prechádzať zdrojové kódy

算法导入改为切片上传大文件优化

zhangliang2 3 rokov pred
rodič
commit
116f2a0c32

+ 2 - 1
src/components/upload/uploadBigFile.vue

@@ -107,6 +107,7 @@ export default {
                 // }
 
                 // console.log("文件MD5:" + md5);
+                
                 // 3. 正在创建分片
                 let chunkSize = this.chunkSize;
 
@@ -173,7 +174,7 @@ export default {
                 if (mergeResult) {
                     this.success();
                     this.attachmentList.push({
-                        fileName: currentFile.name,
+                        fileName: this.uploadIdInfo.objectName,
                     });
                     this.$emit("attachmentChange", this.attachmentList);
                 }

+ 24 - 9
src/views/algorithmsLibrary/exportAlgorithms.vue

@@ -171,8 +171,6 @@ export default {
                 },
             }).then((res) => {
                 if (res.code == 200 && res.info) {
-                    // console.log(res.info);
-
                     if (this.percentage >= res.info * 100) {
                         if (+res.info === 0) {
                             this.step++;
@@ -213,23 +211,40 @@ export default {
         willUpload() {
             this.isUploading = true;
 
-            // this.timer = setInterval(() => {
-            //     this.onProgress();
-            // }, 4500);
+            this.timer = setInterval(() => {
+                if (this.percentage >= 99) {
+                    this.percentage = 99;
+                    clearInterval(this.timer);
+                    this.timer = null;
+                } else {
+                    this.percentage++;
+                }
+                console.log(this.percentage);
+            }, 4500);
         },
         // 上传完成
         didUpload(state) {
+            if (this.timer) {
+                clearInterval(this.timer);
+                this.timer = null;
+            }
+
             this.isUploading = false;
-            // clearInterval(this.timer);
-            // this.timer = null;
             this.percentage = 0;
             // this.step = 0;
             this.objectPath = this.$getObjectPathByRandom();
         },
         // 进度变化
         percentageChange(val) {
-            if (val > 100) val = 100;
-            this.percentage = val;
+            if (this.timer) {
+                clearInterval(this.timer);
+                this.timer = null;
+            }
+
+            if (this.percentage < val) {
+                if (val > 99) val = 99;
+                this.percentage = val;
+            }
         },
     },