import React, { useState } from 'react'; import { Upload as UploadSource } from 'antd'; import { UploadProps, DraggerProps } from 'antd/es/upload'; import { PlusOutlined, LoadingOutlined, InboxOutlined } from '@ant-design/icons'; export type TUploadProps = UploadProps & { max?: number; // 图片上限,默认为 1,也就是单图片上传 }; /** * 文件上传 */ export const Upload: React.FC = ({ max = 1, onChange, fileList = [], ...props }) => { const [loading, setLoading] = useState(false); return ( 1} onChange={info => { setLoading(info.file.status === 'uploading'); onChange?.(info); }} fileList={fileList} {...props} > {fileList.length < max && ( <> {loading ? : }
上传图片
)}
); }; /** * 拖拽上传 */ export const UploadDragger: React.FC = ({ onChange, ...props }) => { return (

点击或拖文件到这个区域上传

支持多个文件或文件夹上传。

); };