* fix: support folder drag-and-drop upload with directory structure preserved Drag-dropping a folder onto the knowledge base page was treated as a single phantom file (size 0, no extension) and failed with "unsupported file type" on Chrome/Edge, or silently did nothing on Firefox. Root cause: collectDroppedFiles checked dataTransfer.files first, which Chrome/Edge populates with non-traversable directory entries for folder drops. The function never reached the webkitGetAsEntry branch that can recursively traverse directory contents. Fix: reverse the priority — try webkitGetAsEntry first to recursively traverse dropped directories, setting webkitRelativePath on each File to preserve the folder structure (same format as <input webkitdirectory>). Fall back to dataTransfer.files only for plain file drags or browsers without webkitGetAsEntry support. Additional details: - readEntries() is called in a loop until empty (batches may be partial) - Hidden files/directories (segments starting with .) are skipped, matching the button-based folder upload behavior - Top-level dropped files keep webkitRelativePath empty so they upload as individual files, not folder uploads - Object.defineProperty is used with try/catch for Safari compatibility Closes #2676 * style: switch code comments to Chinese for consistency with existing file * fix: don't fall back to phantom files after directory drag-drop Once webkitGetAsEntry returns entries, trust the traversal result even when it is empty (empty or hidden-only folders). Falling back to dataTransfer.files reintroduced Chrome/Edge's size-0 directory File. Also isolate per-item failures and cover the collector with unit tests. --------- Co-authored-by: wizardchen <wizardchen@tencent.com> |
||
|---|---|---|
| .. | ||
| packages | ||
| public | ||
| src | ||
| .dockerignore | ||
| .gitignore | ||
| Dockerfile | ||
| docker-entrypoint.sh | ||
| embed.html | ||
| env.d.ts | ||
| index.html | ||
| nginx.conf | ||
| package-lock.json | ||
| package.json | ||
| package.json.md5 | ||
| pnpm-workspace.yaml | ||
| tsconfig.app.json | ||
| tsconfig.json | ||
| tsconfig.node.json | ||
| vite.config.ts | ||