Просмотр исходного кода

【我的素材】除了全景图片上传这个特殊操作,其他上传操作完成后都刷新素材列表。

任一存 4 лет назад
Родитель
Сommit
a0e2152fd2

+ 1 - 0
src/components/shared/uploads/UploadMultiple.vue

@@ -44,6 +44,7 @@ export default {
 
       this.files = e.target.files;
 
+      // 对选中的文件按照格式限制和尺寸限制做过滤
       this.files = Array.from(this.files).filter((item, i) => {
         if (!fileInfo.checkMediaMime(this.mediaType, item.name)) {
           setTimeout(() => {

+ 6 - 2
src/views/material/audio/index.vue

@@ -133,7 +133,7 @@ import rename from "../popup/rename";
 import vAudio from "@/components/audio";
 import Upload from "@/components/shared/uploads/UploadMultiple";
 import { changeByteUnit } from "@/utils/file";
-import UploadList from "../components/uploadList";
+import UploadList from "../components/uploadList.vue";
 import { debounce } from "@/utils/other.js"
 
 import {
@@ -276,6 +276,7 @@ export default {
     onFileChange(file) {
       let canUploadList = [];
 
+      // 对选中的文件按照格式限制和名称长度限制,做过滤,name存到this.uploadList,整个file对象存到canUploadList。
       file.files.forEach((item, i) => {
         let tmp = {
           statusStr: "上传中",
@@ -313,6 +314,7 @@ export default {
         });
       });
 
+      // Promise对象数组,每个Promise都会马上被canUploadList里的元素resolve。
       let p = [];
       canUploadList.forEach((i) => {
         let promise = new Promise((resolve) => {
@@ -322,6 +324,7 @@ export default {
       });
 
       Promise.all(p).then((result) => {
+        // pp保存了每个文件的上传任务的Promise对象。
         let pp = [];
         p.length > 0 &&
           result.forEach((data) => {
@@ -345,6 +348,7 @@ export default {
             pp.push(promise);
           });
         pp.length > 0 &&
+          // 上传任务都结束后,this.uploadList里记录的所有任务状态都更新到5,this.uploadList里删除那些结束了的任务,更新列表数据。
           Promise.all(pp).then((response) => {
             if (response.length > 0) {
               this.uploadList.forEach((item) => {
@@ -361,7 +365,7 @@ export default {
                   }
                 }
               });
-              this.getMoreMaterialItem();
+              this.refreshListDebounced()
             }
           });
       });

+ 1 - 1
src/views/material/image/index.vue

@@ -356,7 +356,7 @@ export default {
                   }
                 }
               });
-              this.getMoreMaterialItem();
+              this.refreshListDebounced()
             }
           });
       });

+ 1 - 1
src/views/material/video/index.vue

@@ -353,7 +353,7 @@ export default {
                   }
                 }
               });
-              this.getMoreMaterialItem();
+              this.refreshListDebounced()
             }
           });
       });