From e2d7fe9c72fb67b5d6c55fe5ac2c7867cfe53344 Mon Sep 17 00:00:00 2001 From: lif <1835304752@qq.com> Date: Thu, 22 Jan 2026 19:51:24 +0800 Subject: [PATCH] fix(web): use Array.from() for FileList to fix tsc type errors (#31398) --- .github/workflows/style.yml | 2 +- .../annotation/batch-add-annotation-modal/csv-uploader.tsx | 2 +- web/app/components/app/create-from-dsl-modal/uploader.tsx | 2 +- web/app/components/apps/hooks/use-dsl-drag-drop.ts | 2 +- .../create-options/create-from-dsl-modal/uploader.tsx | 2 +- web/app/components/datasets/create/file-uploader/index.tsx | 2 +- .../create-from-pipeline/data-source/local-file/index.tsx | 4 ++-- .../datasets/documents/detail/batch-modal/csv-uploader.tsx | 2 +- web/app/components/plugins/plugin-page/use-uploader.ts | 2 +- 9 files changed, 10 insertions(+), 10 deletions(-) diff --git a/.github/workflows/style.yml b/.github/workflows/style.yml index 5551030f1e..fdc05d1d65 100644 --- a/.github/workflows/style.yml +++ b/.github/workflows/style.yml @@ -125,7 +125,7 @@ jobs: - name: Web type check if: steps.changed-files.outputs.any_changed == 'true' working-directory: ./web - run: pnpm run type-check:tsgo + run: pnpm run type-check - name: Web dead code check if: steps.changed-files.outputs.any_changed == 'true' diff --git a/web/app/components/app/annotation/batch-add-annotation-modal/csv-uploader.tsx b/web/app/components/app/annotation/batch-add-annotation-modal/csv-uploader.tsx index 28489a6714..6d5eb1ef95 100644 --- a/web/app/components/app/annotation/batch-add-annotation-modal/csv-uploader.tsx +++ b/web/app/components/app/annotation/batch-add-annotation-modal/csv-uploader.tsx @@ -48,7 +48,7 @@ const CSVUploader: FC = ({ setDragging(false) if (!e.dataTransfer) return - const files = [...e.dataTransfer.files] + const files = Array.from(e.dataTransfer.files) if (files.length > 1) { notify({ type: 'error', message: t('stepOne.uploader.validation.count', { ns: 'datasetCreation' }) }) return diff --git a/web/app/components/app/create-from-dsl-modal/uploader.tsx b/web/app/components/app/create-from-dsl-modal/uploader.tsx index 133bd34dbc..778a2c1420 100644 --- a/web/app/components/app/create-from-dsl-modal/uploader.tsx +++ b/web/app/components/app/create-from-dsl-modal/uploader.tsx @@ -58,7 +58,7 @@ const Uploader: FC = ({ setDragging(false) if (!e.dataTransfer) return - const files = [...e.dataTransfer.files] + const files = Array.from(e.dataTransfer.files) if (files.length > 1) { notify({ type: 'error', message: t('stepOne.uploader.validation.count', { ns: 'datasetCreation' }) }) return diff --git a/web/app/components/apps/hooks/use-dsl-drag-drop.ts b/web/app/components/apps/hooks/use-dsl-drag-drop.ts index dda5773062..77d89b87da 100644 --- a/web/app/components/apps/hooks/use-dsl-drag-drop.ts +++ b/web/app/components/apps/hooks/use-dsl-drag-drop.ts @@ -36,7 +36,7 @@ export const useDSLDragDrop = ({ onDSLFileDropped, containerRef, enabled = true if (!e.dataTransfer) return - const files = [...e.dataTransfer.files] + const files = Array.from(e.dataTransfer.files) if (files.length === 0) return diff --git a/web/app/components/datasets/create-from-pipeline/create-options/create-from-dsl-modal/uploader.tsx b/web/app/components/datasets/create-from-pipeline/create-options/create-from-dsl-modal/uploader.tsx index 2f5130ecce..3fa940c60d 100644 --- a/web/app/components/datasets/create-from-pipeline/create-options/create-from-dsl-modal/uploader.tsx +++ b/web/app/components/datasets/create-from-pipeline/create-options/create-from-dsl-modal/uploader.tsx @@ -54,7 +54,7 @@ const Uploader: FC = ({ setDragging(false) if (!e.dataTransfer) return - const files = [...e.dataTransfer.files] + const files = Array.from(e.dataTransfer.files) if (files.length > 1) { notify({ type: 'error', message: t('stepOne.uploader.validation.count', { ns: 'datasetCreation' }) }) return diff --git a/web/app/components/datasets/create/file-uploader/index.tsx b/web/app/components/datasets/create/file-uploader/index.tsx index e9c6693e52..781b97200a 100644 --- a/web/app/components/datasets/create/file-uploader/index.tsx +++ b/web/app/components/datasets/create/file-uploader/index.tsx @@ -278,7 +278,7 @@ const FileUploader = ({ onFileListUpdate?.([...fileListRef.current]) } const fileChangeHandle = useCallback((e: React.ChangeEvent) => { - let files = [...(e.target.files ?? [])] as File[] + let files = Array.from(e.target.files ?? []) as File[] files = files.slice(0, fileUploadConfig.batch_count_limit) initialUpload(files.filter(isValid)) }, [isValid, initialUpload, fileUploadConfig]) diff --git a/web/app/components/datasets/documents/create-from-pipeline/data-source/local-file/index.tsx b/web/app/components/datasets/documents/create-from-pipeline/data-source/local-file/index.tsx index a5c03b671a..d02d5927f2 100644 --- a/web/app/components/datasets/documents/create-from-pipeline/data-source/local-file/index.tsx +++ b/web/app/components/datasets/documents/create-from-pipeline/data-source/local-file/index.tsx @@ -230,7 +230,7 @@ const LocalFile = ({ if (!e.dataTransfer) return - let files = [...e.dataTransfer.files] as File[] + let files = Array.from(e.dataTransfer.files) as File[] if (!supportBatchUpload) files = files.slice(0, 1) @@ -251,7 +251,7 @@ const LocalFile = ({ updateFileList([...fileListRef.current]) } const fileChangeHandle = useCallback((e: React.ChangeEvent) => { - let files = [...(e.target.files ?? [])] as File[] + let files = Array.from(e.target.files ?? []) as File[] files = files.slice(0, fileUploadConfig.batch_count_limit) initialUpload(files.filter(isValid)) }, [isValid, initialUpload, fileUploadConfig.batch_count_limit]) diff --git a/web/app/components/datasets/documents/detail/batch-modal/csv-uploader.tsx b/web/app/components/datasets/documents/detail/batch-modal/csv-uploader.tsx index 0ca404a26e..f3a86e910d 100644 --- a/web/app/components/datasets/documents/detail/batch-modal/csv-uploader.tsx +++ b/web/app/components/datasets/documents/detail/batch-modal/csv-uploader.tsx @@ -126,7 +126,7 @@ const CSVUploader: FC = ({ setDragging(false) if (!e.dataTransfer) return - const files = [...e.dataTransfer.files] + const files = Array.from(e.dataTransfer.files) if (files.length > 1) { notify({ type: 'error', message: t('stepOne.uploader.validation.count', { ns: 'datasetCreation' }) }) return diff --git a/web/app/components/plugins/plugin-page/use-uploader.ts b/web/app/components/plugins/plugin-page/use-uploader.ts index 8c8b4a68c2..7df1cb95e3 100644 --- a/web/app/components/plugins/plugin-page/use-uploader.ts +++ b/web/app/components/plugins/plugin-page/use-uploader.ts @@ -36,7 +36,7 @@ export const useUploader = ({ onFileChange, containerRef, enabled = true }: Uplo setDragging(false) if (!e.dataTransfer) return - const files = [...e.dataTransfer.files] + const files = Array.from(e.dataTransfer.files) if (files.length > 0) onFileChange(files[0]) }