From f056cc862588e714c4755c9a724075b92d546c68 Mon Sep 17 00:00:00 2001 From: duxingchen Date: Thu, 13 Aug 2026 09:07:10 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=9B=BE=E7=89=87URL=E5=8F=8C=E9=87=8D/?= =?UTF-8?q?api/v1=E5=89=8D=E7=BC=80=E5=AF=BC=E8=87=B4404?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 根因: 后端返回 /api/v1/upload/files/xxx.jpg 前端imageUrl又拼VITE_API_BASE_URL=/api/v1 → /api/v1/api/v1/upload/files/xxx.jpg → 404 修复: /api/开头的URL直接返回, 不再拼接前缀 --- frontend/src/components/TaskTree/TaskFlowView.tsx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/frontend/src/components/TaskTree/TaskFlowView.tsx b/frontend/src/components/TaskTree/TaskFlowView.tsx index 65e11c3..9c79e2b 100644 --- a/frontend/src/components/TaskTree/TaskFlowView.tsx +++ b/frontend/src/components/TaskTree/TaskFlowView.tsx @@ -28,7 +28,12 @@ function parseImages(s: any): string[] { if (typeof s === "string") { try { return JSON.parse(s); } catch { return []; } } return []; } -function imageUrl(u: string) { if (!u) return ""; return u.startsWith("http") ? u : import.meta.env.VITE_API_BASE_URL + (u.startsWith("/") ? u : "/" + u); } +function imageUrl(u: string) { + if (!u) return ""; + if (u.startsWith("http")) return u; // 绝对地址直接用 + if (u.startsWith("/api/")) return u; // 已是完整API路径,避免双重/api/v1前缀 + return import.meta.env.VITE_API_BASE_URL + (u.startsWith("/") ? u : "/" + u); +} const ALL_TASKS = new Set(); function collectAll(tasks: TaskResponse[]) { tasks.forEach(t => { ALL_TASKS.add(t); if (t.child_tasks) collectAll(t.child_tasks); }); }