diff --git a/src/components/DocumentCockpit.tsx b/src/components/DocumentCockpit.tsx index 1730f21..8f33889 100644 --- a/src/components/DocumentCockpit.tsx +++ b/src/components/DocumentCockpit.tsx @@ -64,8 +64,13 @@ export function DocumentCockpit() { useEffect(() => { let c = false setProjects(null); setPid(''); setOverview(null); setSelected(null); setFilter(''); setError('') - api.rdmCommand('rdm.project.list') - .then(list => { if (!c) setProjects(Array.isArray(list) ? list : []) }) + api.rdmCommand<{ projects?: ProjectView[] } | ProjectView[]>('rdm.project.list') + .then(list => { + if (!c) return + // rdm.project.list 返回 { projects: [...] };容忍裸数组形态。 + const rows = Array.isArray(list) ? list : (list?.projects ?? []) + setProjects(rows) + }) .catch(e => { if (!c) setError(e.message) }) return () => { c = true } }, [identity])