Skip to content

Commit

Permalink
fix: 🐛 修复upload组件,value参数问题,value参数会被过滤掉
Browse files Browse the repository at this point in the history
  • Loading branch information
liuxingyun2010 committed Sep 3, 2024
1 parent 37e7aeb commit 4349c43
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
9 changes: 4 additions & 5 deletions components/upload/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import httpConsole from '../utils/httpConsole'

export interface UploadProps extends AntdUploadProps {
ticket: string
value?: any
onChange?: (params: any) => void
max?: number
}
Expand Down Expand Up @@ -44,7 +43,7 @@ export interface IOssData {
const Upload: FC<UploadProps> = ({
ticket,
max = -1,
value,
fileList = [],
onChange: onInitialOnChange,
children,
beforeUpload,
Expand Down Expand Up @@ -84,7 +83,7 @@ const Upload: FC<UploadProps> = ({
}

const onRemove = (file: any) => {
const files = value.filter((v: any) => v.url !== file.url)
const files = fileList.filter((v: any) => v.url !== file.url)
if (onInitialOnChange) {
onInitialOnChange(files)
}
Expand Down Expand Up @@ -116,7 +115,7 @@ const Upload: FC<UploadProps> = ({

const props = {
name: 'file',
fileList: value,
fileList,
action: OSSData.host,
onChange,
onRemove,
Expand All @@ -128,7 +127,7 @@ const Upload: FC<UploadProps> = ({

return (
<AntdUpload {...props}>
{value?.length === max
{fileList?.length === max
? null
: children || (
<Button>
Expand Down
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -132,5 +132,8 @@
"commitizen": {
"path": "cz-conventional-changelog"
}
},
"resolutions": {
"js-cookie": "^2.2.0"
}
}
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -10631,6 +10631,11 @@ joi2types@~1.0.7:
"@types/json-schema" "^7.0.4"
json-schema-to-typescript "^8.2.0"

js-cookie@^2.2.0:
version "2.2.1"
resolved "https://registry.npmmirror.com/js-cookie/-/js-cookie-2.2.1.tgz#69e106dc5d5806894562902aa5baec3744e9b2b8"
integrity sha512-HvdH2LzI/EAZcUwA8+0nKNtWHqS+ZmijLA30RwZA0bo7ToCckjK5MkGhjED9KoRcXO6BaGI3I9UIzSA1FKFPOQ==

js-cookie@^3.0.5:
version "3.0.5"
resolved "https://registry.npmmirror.com/js-cookie/-/js-cookie-3.0.5.tgz#0b7e2fd0c01552c58ba86e0841f94dc2557dcdbc"
Expand Down

0 comments on commit 4349c43

Please sign in to comment.