fix(web): file upload bugfix

This commit is contained in:
zhaoying
2026-02-11 11:34:20 +08:00
parent 41334f5f1e
commit 32b40fc6bf

View File

@@ -2,7 +2,7 @@
* @Author: ZhaoYing * @Author: ZhaoYing
* @Date: 2026-02-06 21:09:42 * @Date: 2026-02-06 21:09:42
* @Last Modified by: ZhaoYing * @Last Modified by: ZhaoYing
* @Last Modified time: 2026-02-10 17:40:08 * @Last Modified time: 2026-02-11 11:32:48
*/ */
/** /**
* File Upload Component * File Upload Component
@@ -167,7 +167,7 @@ const UploadFiles = forwardRef<UploadFilesRef, UploadFilesProps>(({
formData.append('file', file); formData.append('file', file);
const response = await request.uploadFile(action, formData, requestConfig); const response = await request.uploadFile(action, formData, requestConfig);
onSuccess?.({data: response}); onSuccess?.({data: response});
} catch (error) { } catch (error) {
onError?.(error as Error); onError?.(error as Error);
@@ -178,8 +178,9 @@ const UploadFiles = forwardRef<UploadFilesRef, UploadFilesProps>(({
* Handles upload state changes * Handles upload state changes
*/ */
const handleChange: UploadProps['onChange'] = ({ fileList: newFileList }) => { const handleChange: UploadProps['onChange'] = ({ fileList: newFileList }) => {
setFileList(newFileList);
if (onChange) { if (onChange) {
onChange(maxCount === 1 ? newFileList[0] : newFileList); onChange(maxCount === 1 ? newFileList[newFileList.length - 1] : newFileList);
} }
}; };