Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
dify
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ai-tech
dify
Commits
93b84d8a
Commit
93b84d8a
authored
Jun 20, 2023
by
Joel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: chose not reset before files
parent
5d43e2d3
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
8 deletions
+10
-8
index.tsx
web/app/components/datasets/create/file-uploader/index.tsx
+10
-8
No files found.
web/app/components/datasets/create/file-uploader/index.tsx
View file @
93b84d8a
...
...
@@ -46,7 +46,7 @@ const FileUploader = ({
const
dragRef
=
useRef
<
HTMLDivElement
>
(
null
)
const
fileUploader
=
useRef
<
HTMLInputElement
>
(
null
)
const
fileListRef
=
useRef
<
any
>
(
null
)
const
fileListRef
=
useRef
<
any
>
(
[]
)
// utils
const
getFileType
=
(
currentFile
:
File
)
=>
{
...
...
@@ -79,13 +79,12 @@ const FileUploader = ({
}
const
fileUpload
=
async
(
fileItem
:
any
)
=>
{
const
fileListCopy
=
fileListRef
.
current
const
formData
=
new
FormData
()
formData
.
append
(
'file'
,
fileItem
.
file
)
const
onProgress
=
(
e
:
ProgressEvent
)
=>
{
if
(
e
.
lengthComputable
)
{
const
percent
=
Math
.
floor
(
e
.
loaded
/
e
.
total
*
100
)
onFileUpdate
(
fileItem
,
percent
,
fileList
Copy
)
onFileUpdate
(
fileItem
,
percent
,
fileList
Ref
.
current
)
}
}
...
...
@@ -95,6 +94,8 @@ const FileUploader = ({
onprogress
:
onProgress
,
})
.
then
((
res
:
FileEntity
)
=>
{
const
fileListCopy
=
fileListRef
.
current
const
completeFile
=
{
fileID
:
fileItem
.
fileID
,
file
:
res
,
...
...
@@ -141,8 +142,9 @@ const FileUploader = ({
}
return
fileItem
})
prepareFileList
(
preparedFiles
)
fileListRef
.
current
=
preparedFiles
const
newFiles
=
[...
fileListRef
.
current
,
...
preparedFiles
]
prepareFileList
(
newFiles
)
fileListRef
.
current
=
newFiles
uploadMultipleFiles
(
preparedFiles
)
}
const
handleDragEnter
=
(
e
:
DragEvent
)
=>
{
...
...
@@ -178,11 +180,11 @@ const FileUploader = ({
fileUploader
.
current
.
click
()
}
const
removeFile
=
(
index
:
number
)
=>
{
const
removeFile
=
(
fileID
:
string
)
=>
{
if
(
fileUploader
.
current
)
fileUploader
.
current
.
value
=
''
fileListRef
.
current
.
splice
(
index
,
1
)
fileListRef
.
current
=
fileListRef
.
current
.
filter
((
item
:
any
)
=>
item
.
fileID
!==
fileID
)
onFileListUpdate
?.([...
fileListRef
.
current
])
}
const
fileChangeHandle
=
(
e
:
React
.
ChangeEvent
<
HTMLInputElement
>
)
=>
{
...
...
@@ -250,7 +252,7 @@ const FileUploader = ({
{
fileItem
.
progress
===
100
&&
(
<
div
className=
{
s
.
remove
}
onClick=
{
(
e
)
=>
{
e
.
stopPropagation
()
removeFile
(
index
)
removeFile
(
fileItem
.
fileID
)
}
}
/>
)
}
</
div
>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment