From febf8b6c67252b49ad51918e9d27a227cab39801 Mon Sep 17 00:00:00 2001 From: chengkai3 Date: Sun, 28 Jun 2026 22:43:46 +0800 Subject: [PATCH] =?UTF-8?q?[fix]:[FL-226][ATP=E6=A8=A1=E5=9E=8B=E4=B8=8A?= =?UTF-8?q?=E4=BC=A0=E6=97=B6=E5=8E=BB=E6=8E=89=E6=9C=80=E5=A4=96=E5=B1=82?= =?UTF-8?q?=E7=9B=AE=E5=BD=95]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修改上传逻辑,在打包ZIP时自动去掉选中文件夹的最外层目录名, 只保留里面的文件和子目录结构。 示例: - 选择文件夹:/my-model/subdir/file.txt - 之前上传后:my-model/subdir/file.txt - 现在上传后:subdir/file.txt 实现细节: - 解析webkitRelativePath,按/分割路径 - 使用slice(1)去掉第一个路径段(最外层目录名) - 重新拼接剩余路径段 Co-Authored-By: Claude Sonnet 4.6 Co-authored-by: multica-agent --- web/src/app/admin/atp-models/page.tsx | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/web/src/app/admin/atp-models/page.tsx b/web/src/app/admin/atp-models/page.tsx index 104b2b2..af3f8b9 100644 --- a/web/src/app/admin/atp-models/page.tsx +++ b/web/src/app/admin/atp-models/page.tsx @@ -241,8 +241,13 @@ export default function AtpModelsPage() { const JSZip = (await import("jszip")).default; const zip = new JSZip(); for (const file of values.files) { - const path = (file as any).webkitRelativePath || file.name; - zip.file(path, file); + const fullPath = (file as any).webkitRelativePath || file.name; + // Strip the outermost directory level + const pathParts = fullPath.split('/'); + const strippedPath = pathParts.length > 1 ? pathParts.slice(1).join('/') : fullPath; + if (strippedPath) { + zip.file(strippedPath, file); + } } const zipBlob = await zip.generateAsync({ type: "blob" }); formData.append("files", zipBlob, "model.zip");