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,6 +47,7 @@ | ||
47 | transformFile?: (file: File) => string | Blob | Promise<string | Blob | File>; | 47 | transformFile?: (file: File) => string | Blob | Promise<string | Blob | File>; |
48 | api: (file: string | Blob | Promise<string | Blob | File>) => Promise<FileItem>; | 48 | api: (file: string | Blob | Promise<string | Blob | File>) => Promise<FileItem>; |
49 | overFileLimitHiddenUploadEntry?: boolean; | 49 | overFileLimitHiddenUploadEntry?: boolean; |
50 | + beforeUpload: (file: File, fileList: File[]) => boolean; | ||
50 | }>(), | 51 | }>(), |
51 | { | 52 | { |
52 | fileList: () => [], | 53 | fileList: () => [], |
@@ -57,7 +58,11 @@ | @@ -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 | if (file.size > props.maxSize) { | 66 | if (file.size > props.maxSize) { |
62 | createMessage.warning(`文件大小超过${Math.floor(props.maxSize / 1024 / 1024)}mb`); | 67 | createMessage.warning(`文件大小超过${Math.floor(props.maxSize / 1024 / 1024)}mb`); |
63 | return false; | 68 | return false; |
@@ -129,6 +134,7 @@ | @@ -129,6 +134,7 @@ | ||
129 | <template> | 134 | <template> |
130 | <Upload | 135 | <Upload |
131 | class="block" | 136 | class="block" |
137 | + :accept="accept" | ||
132 | :class="prefixCls" | 138 | :class="prefixCls" |
133 | :file-list="props.fileList" | 139 | :file-list="props.fileList" |
134 | :list-type="props.listType" | 140 | :list-type="props.listType" |