wangfumin 3 місяців тому
батько
коміт
681f372ded
1 змінених файлів з 14 додано та 11 видалено
  1. 14 11
      src/view/mediaLibrary/uploadMedia.vue

+ 14 - 11
src/view/mediaLibrary/uploadMedia.vue

@@ -128,18 +128,21 @@ const changeGroup = (value) => {
 };
 // 处理文件变化
 const handleFileChange = (file, files) => {
-  // 检查文件类型和大小
-  const isValidFile = validateFile(file);
-  if (!isValidFile) {
-    // 如果文件无效,从文件列表中移除
-    const index = files.indexOf(file);
-    if (index !== -1) {
-      files.splice(index, 1);
+  if(file){
+    // 检查文件类型和大小
+    const isValidFile = validateFile(file);
+    if (!isValidFile) {
+      // 如果文件无效,从文件列表中移除
+      const index = files.indexOf(file);
+      if (index !== -1) {
+        files.splice(index, 1);
+      }
+      return;
     }
-    return;
+    fileList.value = [file];
+  } else {
+    fileList.value = [];
   }
-  
-  fileList.value = [file];
 };
 
 // 验证文件类型和大小
@@ -194,7 +197,7 @@ const validateFile = (file) => {
 
 // 处理文件删除
 const handleFileRemove = (file, fileList) => {
-  handleFileChange({}, []);
+  handleFileChange('', []);
 };
 
 // 关闭弹窗