perf: parallelize file uploads and add consistent drag validation

Use Promise.all for concurrent file uploads instead of sequential
processing, improving upload performance for multiple files. Also
add isFileDrag check to handleFolderDragOver for consistency with
other drag handlers.
This commit is contained in:
yyh
2026-01-19 18:02:15 +08:00
parent c979b59e1e
commit fe0ea13f70
2 changed files with 11 additions and 9 deletions

View File

@ -71,14 +71,16 @@ export function useFileDrop() {
return
try {
for (const file of files) {
await createFile.mutateAsync({
appId,
name: file.name,
file,
parentId: targetFolderId,
})
}
await Promise.all(
files.map(file =>
createFile.mutateAsync({
appId,
name: file.name,
file,
parentId: targetFolderId,
}),
),
)
Toast.notify({
type: 'success',

View File

@ -62,7 +62,7 @@ export function useFolderFileDrop(node: NodeApi<TreeNodeData>): UseFolderFileDro
}, [isFolder, scheduleAutoExpand])
const handleFolderDragOver = useCallback((e: React.DragEvent) => {
if (!isFolder)
if (!isFolder || !isFileDrag(e))
return
handleDragOver(e, { folderId: node.data.id, isFolder: true })
}, [handleDragOver, isFolder, node.data.id])