mirror of
https://git.mirrors.martin98.com/https://github.com/langgenius/dify.git
synced 2025-08-12 19:18:58 +08:00
fix: upload file component support multiple (#10817)
This commit is contained in:
parent
7261384655
commit
133de9a087
@ -13,10 +13,19 @@ const FileInput = ({
|
|||||||
const files = useStore(s => s.files)
|
const files = useStore(s => s.files)
|
||||||
const { handleLocalFileUpload } = useFile(fileConfig)
|
const { handleLocalFileUpload } = useFile(fileConfig)
|
||||||
const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
||||||
const file = e.target.files?.[0]
|
const targetFiles = e.target.files
|
||||||
|
|
||||||
if (file)
|
if (targetFiles) {
|
||||||
handleLocalFileUpload(file)
|
if (fileConfig.number_limits) {
|
||||||
|
for (let i = 0; i < targetFiles.length; i++) {
|
||||||
|
if (i + 1 + files.length <= fileConfig.number_limits)
|
||||||
|
handleLocalFileUpload(targetFiles[i])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
handleLocalFileUpload(targetFiles[0])
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const allowedFileTypes = fileConfig.allowed_file_types
|
const allowedFileTypes = fileConfig.allowed_file_types
|
||||||
@ -32,6 +41,7 @@ const FileInput = ({
|
|||||||
onChange={handleChange}
|
onChange={handleChange}
|
||||||
accept={accept}
|
accept={accept}
|
||||||
disabled={!!(fileConfig.number_limits && files.length >= fileConfig?.number_limits)}
|
disabled={!!(fileConfig.number_limits && files.length >= fileConfig?.number_limits)}
|
||||||
|
multiple={!!fileConfig.number_limits && fileConfig.number_limits > 1}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user