From 7e4e44ee2c05288ee0e26ab3ecb13ab7b80fce89 Mon Sep 17 00:00:00 2001 From: zhouyun1 Date: Wed, 3 Jul 2024 16:47:52 +0800 Subject: [PATCH 1/2] =?UTF-8?q?fix(upload):=20=E4=BF=AE=E5=A4=8D=E8=AE=BE?= =?UTF-8?q?=E7=BD=AE=20maxCount=20=E5=90=8E=E4=B8=8A=E4=BC=A0=E6=97=B6?= =?UTF-8?q?=E6=8A=A5=E9=94=99=E9=97=AE=E9=A2=98=20(#2928)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .changeset/calm-coins-leave.md | 5 +++++ .changeset/orange-waves-allow.md | 5 +++++ packages/ui/upload/src/NormalUpload.tsx | 1 + packages/ui/upload/src/PictureListUpload.tsx | 1 + packages/ui/upload/src/PictureUpload.tsx | 1 + packages/ui/upload/src/hooks/use-upload.ts | 3 ++- 6 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 .changeset/calm-coins-leave.md create mode 100644 .changeset/orange-waves-allow.md 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] From 5e78774a4b93bfe5b5cd8f6c917ad91e9a05d1ad Mon Sep 17 00:00:00 2001 From: zhouyun1 Date: Sun, 14 Jul 2024 16:46:24 +0800 Subject: [PATCH 2/2] =?UTF-8?q?chore(upload):=20=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E6=8B=96=E6=8B=BD=E6=A0=B7=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/ui/upload/src/styles/upload.scss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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;