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();