From a5e256330a6730a19e61ef291431888d3edafa54 Mon Sep 17 00:00:00 2001 From: duxingchen Date: Wed, 12 Aug 2026 16:08:37 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20parseImages=E6=94=AF=E6=8C=81=E6=95=B0?= =?UTF-8?q?=E7=BB=84=E8=BE=93=E5=85=A5=20=E2=80=94=20Pydantic=E5=BA=8F?= =?UTF-8?q?=E5=88=97=E5=8C=96=E5=90=8Eimages=E5=B7=B2=E6=98=AF=E6=95=B0?= =?UTF-8?q?=E7=BB=84=E9=9D=9E=E5=AD=97=E7=AC=A6=E4=B8=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/components/TaskTree/TaskFlowView.tsx | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/frontend/src/components/TaskTree/TaskFlowView.tsx b/frontend/src/components/TaskTree/TaskFlowView.tsx index 3813d18..65e11c3 100644 --- a/frontend/src/components/TaskTree/TaskFlowView.tsx +++ b/frontend/src/components/TaskTree/TaskFlowView.tsx @@ -22,7 +22,12 @@ function ArrowRight({ color = "#9ca3af" }: { color?: string }) { function ArrowLeft({ color = "#9ca3af" }: { color?: string }) { return ; } -function parseImages(s: string | null | undefined): string[] { if (!s) return []; try { return JSON.parse(s); } catch { return []; } } +function parseImages(s: any): string[] { + if (!s) return []; + if (Array.isArray(s)) return s; // Pydantic 序列化后的数组 + 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); } const ALL_TASKS = new Set(); @@ -218,7 +223,7 @@ export const TaskFlowView = memo(function TaskFlowView({ tasks, onAction, curren

{fmtTime(r.created_at)}

{(r.note || r.remark) &&

{r.note || r.remark}

} - {(() => { const imgs = parseImages((r as any).images); if (!imgs.length) return null; return
{imgs.map((img, j) => window.open(imageUrl(img))} />)}
; })()} + {(() => { const imgs = parseImages(r.images); if (!imgs.length) return null; return
{imgs.map((img, j) => window.open(imageUrl(img))} />)}
; })()}
))}}