refactor(front): improve file upload progress handling by adding async wait to prevent UI freezing during upload tasks

This commit is contained in:
keven1024
2025-09-29 17:59:09 +08:00
parent d306581e34
commit 6bd008f119

View File

@@ -15,6 +15,7 @@ import showDrawer from '~/lib/showDrawer'
import FileUploadSpeedInfoView from './FileUploadSpeedInfoView.vue'
import getFileChunk from '~/lib/getFileChunk'
import type { FileHandleKey } from '~/components/Preprocessing/types'
import asyncWait from '@/lib/asyncWait'
const props = defineProps<{
data: { file: File[]; config: Record<string, any>; handle_type: FileHandleKey }
@@ -119,6 +120,7 @@ const { error, execute, isLoading } = useAsyncState(
async () => {
while (activeTaskAllQueue.value.length > 0) {
const taskList = uploadfiles?.value?.filter((r) => r.queue.length > 0 && r.status === 'start')
await asyncWait(10) // 让出主线程防止空转导致ui卡死
await Promise.all(
times(batchNum.value, async (i: number) => {
const file = sample(taskList)