From 11ae3260ac3cc033a892729b517714176bf2c45a Mon Sep 17 00:00:00 2001 From: duxingchen Date: Thu, 13 Aug 2026 10:34:45 +0800 Subject: [PATCH] =?UTF-8?q?fix(web):=20=E4=BF=AE=E5=A4=8D=E5=9B=BE?= =?UTF-8?q?=E7=89=87=20URL=20=E6=8B=BC=E6=8E=A5=E9=80=BB=E8=BE=91=EF=BC=8C?= =?UTF-8?q?/api/=20=E8=B7=AF=E5=BE=84=E6=94=AF=E6=8C=81=E5=85=AC=E7=BD=91?= =?UTF-8?q?=E5=9F=9F=E5=90=8D=E5=8E=BB=E9=87=8D=E6=8B=BC=E6=8E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/components/TaskTree/TaskFlowView.tsx | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/frontend/src/components/TaskTree/TaskFlowView.tsx b/frontend/src/components/TaskTree/TaskFlowView.tsx index 9c79e2b..e8791dd 100644 --- a/frontend/src/components/TaskTree/TaskFlowView.tsx +++ b/frontend/src/components/TaskTree/TaskFlowView.tsx @@ -30,9 +30,18 @@ function parseImages(s: any): string[] { } 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); + if (u.startsWith("http")) return u; // 已是完整绝对地址(含跨域域名),直接用 + const base = (import.meta.env.VITE_API_BASE_URL || "").replace(/\/+$/, ""); // 去掉末尾斜杠 + const path = u.startsWith("/") ? u : "/" + u; + // 后端图片固定返回 /api/v1/upload/files/... 这类 /api/ 开头的相对路径, + // 需拼上 base 才能访问到后端;同时避免重复前缀: + // - base 为纯域名(如 https://track_back.iris-rs.cn)→ 正常 base + path + // - base 以 /api 或 /api/v1 结尾 → 先剥掉该段,否则会拼出 /api/api/ 或 /api/v1/api/v1 + if (path.startsWith("/api/")) { + const origin = base.replace(/\/api(\/v\d+)?$/, ""); + return origin + path; + } + return base + path; } const ALL_TASKS = new Set();