Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(upload): #2928 #2936

Merged
merged 2 commits into from
Jul 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/calm-coins-leave.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@hi-ui/upload": patch
---

fix(upload): 修复设置 maxCount 后上传时报错问题
5 changes: 5 additions & 0 deletions .changeset/orange-waves-allow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@hi-ui/hiui": patch
---

fix(upload): 修复设置 maxCount 后上传时报错问题
1 change: 1 addition & 0 deletions packages/ui/upload/src/NormalUpload.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ export const NormalUpload = forwardRef<HTMLDivElement | null, UploadProps>(
onChange,
uploadAction,
maxSize,
maxCount,
name,
withCredentials,
headers,
Expand Down
1 change: 1 addition & 0 deletions packages/ui/upload/src/PictureListUpload.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export const PictureListUpload = forwardRef<HTMLDivElement | null, UploadProps>(
onChange,
uploadAction,
maxSize,
maxCount,
name,
withCredentials,
headers,
Expand Down
1 change: 1 addition & 0 deletions packages/ui/upload/src/PictureUpload.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ export const PictureUpload = forwardRef<HTMLDivElement | null, UploadProps>(
onChange,
uploadAction,
maxSize,
maxCount,
name,
withCredentials,
headers,
Expand Down
3 changes: 2 additions & 1 deletion packages/ui/upload/src/hooks/use-upload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion packages/ui/upload/src/styles/upload.scss
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down