diff --git a/src/components/CockpitReader.tsx b/src/components/CockpitReader.tsx index 6e94f55..0326236 100644 --- a/src/components/CockpitReader.tsx +++ b/src/components/CockpitReader.tsx @@ -36,7 +36,14 @@ function useNodeDetail(pid: string, sel?: CockpitNodeRef) { setDetail(null); setErr('') if (!sel) return api.rdmCommand('rdm.cockpit.node', { projectId: pid, kind: sel.kind, id: sel.id }) - .then(d => { if (g === gen.current) setDetail(d) }) + .then(d => { + if (g !== gen.current) return + // 后端空列表可能投影为 null(Go nil slice);统一归一,消费端按数组使用。 + for (const k of ['sources', 'history', 'impacts', 'conflicts'] as const) { + if (d?.[k] && !Array.isArray(d[k].items)) d[k].items = [] + } + setDetail(d) + }) .catch(e => { if (g === gen.current) setErr(e.message) }) return () => { gen.current++ } }, [pid, sel?.kind, sel?.id])