diff --git a/.changeset/calm-coins-leave.md b/.changeset/calm-coins-leave.md new file mode 100644 index 000000000..43df38b56 --- /dev/null +++ b/.changeset/calm-coins-leave.md @@ -0,0 +1,5 @@ +--- +"@hi-ui/upload": patch +--- + +fix(upload): 修复设置 maxCount 后上传时报错问题 diff --git a/.changeset/orange-waves-allow.md b/.changeset/orange-waves-allow.md new file mode 100644 index 000000000..4c636cfda --- /dev/null +++ b/.changeset/orange-waves-allow.md @@ -0,0 +1,5 @@ +--- +"@hi-ui/hiui": patch +--- + +fix(upload): 修复设置 maxCount 后上传时报错问题 diff --git a/packages/ui/upload/src/NormalUpload.tsx b/packages/ui/upload/src/NormalUpload.tsx index 1a611eb2f..6690e2f38 100644 --- a/packages/ui/upload/src/NormalUpload.tsx +++ b/packages/ui/upload/src/NormalUpload.tsx @@ -58,6 +58,7 @@ export const NormalUpload = forwardRef( onChange, uploadAction, maxSize, + maxCount, name, withCredentials, headers, diff --git a/packages/ui/upload/src/PictureListUpload.tsx b/packages/ui/upload/src/PictureListUpload.tsx index 41ab06fe5..0ff5338a3 100644 --- a/packages/ui/upload/src/PictureListUpload.tsx +++ b/packages/ui/upload/src/PictureListUpload.tsx @@ -55,6 +55,7 @@ export const PictureListUpload = forwardRef( onChange, uploadAction, maxSize, + maxCount, name, withCredentials, headers, diff --git a/packages/ui/upload/src/PictureUpload.tsx b/packages/ui/upload/src/PictureUpload.tsx index d1c520a0e..1ee363ee8 100644 --- a/packages/ui/upload/src/PictureUpload.tsx +++ b/packages/ui/upload/src/PictureUpload.tsx @@ -78,6 +78,7 @@ export const PictureUpload = forwardRef( onChange, uploadAction, maxSize, + maxCount, name, withCredentials, headers, diff --git a/packages/ui/upload/src/hooks/use-upload.ts b/packages/ui/upload/src/hooks/use-upload.ts index 3b78bbe57..a08a4b9d6 100644 --- a/packages/ui/upload/src/hooks/use-upload.ts +++ b/packages/ui/upload/src/hooks/use-upload.ts @@ -168,7 +168,8 @@ const useUpload = ({ if (files) { const items = getFileItems(files, accept) // 最多上传限制数量 - const length = typeof maxCount === 'number' ? maxCount : items.length + const length = + typeof maxCount === 'number' && items.length > maxCount ? maxCount : items.length for (let i = 0; i < length; i++) { const fileItem = items[i] diff --git a/packages/ui/upload/src/styles/upload.scss b/packages/ui/upload/src/styles/upload.scss index b34287ee7..fda7be83d 100644 --- a/packages/ui/upload/src/styles/upload.scss +++ b/packages/ui/upload/src/styles/upload.scss @@ -159,7 +159,7 @@ $prefix: '#{$component-prefix}-upload' !default; width: 100%; background: use-color('gray', 50); // min-height: 172px; - height: 88px; + // height: 88px; box-sizing: border-box; border: 2px dashed use-color('gray', 300); transition: border-color 0.3s;