diff --git a/Cunkebao/src/components/Upload/SimpleFileUpload/index.tsx b/Cunkebao/src/components/Upload/SimpleFileUpload/index.tsx index 8ed346c4..e6b22847 100644 --- a/Cunkebao/src/components/Upload/SimpleFileUpload/index.tsx +++ b/Cunkebao/src/components/Upload/SimpleFileUpload/index.tsx @@ -5,21 +5,25 @@ import { uploadFile } from "@/api/common"; interface SimpleFileUploadProps { onFileUploaded?: (filePath: string) => void; - disabled?: boolean; - className?: string; maxSize?: number; // 最大文件大小(MB) - accept?: string; // 接受的文件类型 + type?: number; // 1: 图片, 2: 视频, 3: 音频, 4: 文件 + slot?: React.ReactNode; } const SimpleFileUpload: React.FC = ({ onFileUploaded, - disabled = false, - className, maxSize = 50, - accept = "*/*", + slot, + type = 4, }) => { const fileInputRef = useRef(null); - const [uploading, setUploading] = useState(false); + + const accept = { + 1: "image/*", + 2: "video/*", + 3: "audio/*", + 4: "*/*", + }; // 验证文件 const validateFile = (file: File): boolean => { @@ -46,8 +50,6 @@ const SimpleFileUpload: React.FC = ({ return; } - setUploading(true); - try { const fileUrl = await uploadFile(file); onFileUploaded?.(fileUrl); @@ -56,7 +58,6 @@ const SimpleFileUpload: React.FC = ({ console.error("文件上传失败:", error); message.error(error.message || "文件上传失败"); } finally { - setUploading(false); if (fileInputRef.current) { fileInputRef.current.value = ""; } @@ -64,7 +65,6 @@ const SimpleFileUpload: React.FC = ({ }; const handleClick = () => { - if (disabled || uploading) return; fileInputRef.current?.click(); }; @@ -73,17 +73,11 @@ const SimpleFileUpload: React.FC = ({ - - - handleMaterialSelect(key)} - style={{ - borderRadius: "8px", - boxShadow: "0 4px 12px rgba(0, 0, 0, 0.15)", - }} - /> - } - trigger={["click"]} - placement="topLeft" - > -