Commit a186d8452d0ee75d33d9c6d4dff06d8d778a7c61
Merge branch 'fix/api-upload' into 'main_dev'
fix: 修复ApiUpload组件无法限制上传文件类型 See merge request yunteng/thingskit-front!852
Showing
1 changed file
with
7 additions
and
1 deletions
| ... | ... | @@ -47,6 +47,7 @@ | 
| 47 | 47 | transformFile?: (file: File) => string | Blob | Promise<string | Blob | File>; | 
| 48 | 48 | api: (file: string | Blob | Promise<string | Blob | File>) => Promise<FileItem>; | 
| 49 | 49 | overFileLimitHiddenUploadEntry?: boolean; | 
| 50 | + beforeUpload: (file: File, fileList: File[]) => boolean; | |
| 50 | 51 | }>(), | 
| 51 | 52 | { | 
| 52 | 53 | fileList: () => [], | 
| ... | ... | @@ -57,7 +58,11 @@ | 
| 57 | 58 | } | 
| 58 | 59 | ); | 
| 59 | 60 | |
| 60 | - const handleBeforeUpload = (file: File) => { | |
| 61 | + const handleBeforeUpload = (file: File, fileList: File[]) => { | |
| 62 | + const { beforeUpload } = props; | |
| 63 | + | |
| 64 | + if (beforeUpload && isFunction(beforeUpload)) return beforeUpload?.(file, fileList); | |
| 65 | + | |
| 61 | 66 | if (file.size > props.maxSize) { | 
| 62 | 67 | createMessage.warning(`文件大小超过${Math.floor(props.maxSize / 1024 / 1024)}mb`); | 
| 63 | 68 | return false; | 
| ... | ... | @@ -129,6 +134,7 @@ | 
| 129 | 134 | <template> | 
| 130 | 135 | <Upload | 
| 131 | 136 | class="block" | 
| 137 | + :accept="accept" | |
| 132 | 138 | :class="prefixCls" | 
| 133 | 139 | :file-list="props.fileList" | 
| 134 | 140 | :list-type="props.listType" | ... | ... |