Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
278b54cf9d |
@@ -29,6 +29,7 @@ interface Selection { ref: CockpitNodeRef; parentDocId?: string }
|
||||
|
||||
export function DocumentCockpit() {
|
||||
const identity = useStore(() => store.getIdentityEpoch())
|
||||
const instanceId = useRef(Math.random().toString(36).slice(2, 8))
|
||||
const [projects, setProjects] = useState<ProjectView[] | null>(null)
|
||||
const [pid, setPid] = useState('')
|
||||
const [filter, setFilter] = useState('')
|
||||
@@ -63,13 +64,16 @@ export function DocumentCockpit() {
|
||||
// 项目清单(rdm.project.list:成员可见项目,canAudit 与否不影响文档读取入口)。
|
||||
useEffect(() => {
|
||||
let c = false
|
||||
console.log('[cockpit-dbg] EFFECT start inst=' + instanceId.current, 'identity=', identity)
|
||||
setProjects(null); setPid(''); setOverview(null); setSelected(null); setFilter(''); setError('')
|
||||
api.rdmCommand<{ projects?: ProjectView[] } | ProjectView[]>('rdm.project.list')
|
||||
.then(list => {
|
||||
const rows = Array.isArray(list) ? list : ((list as any)?.projects ?? [])
|
||||
console.log('[cockpit-dbg] FETCH resolved inst=' + instanceId.current, 'cancelled=', c, 'rows=', rows.length)
|
||||
if (!c) return
|
||||
// rdm.project.list 返回 { projects: [...] };容忍裸数组形态。
|
||||
const rows = Array.isArray(list) ? list : (list?.projects ?? [])
|
||||
setProjects(rows)
|
||||
console.log('[cockpit-dbg] setProjects done inst=' + instanceId.current, 'rows=', rows.length)
|
||||
})
|
||||
.catch(e => { if (!c) setError(e.message) })
|
||||
return () => { c = true }
|
||||
@@ -116,6 +120,7 @@ export function DocumentCockpit() {
|
||||
.catch(() => { /* 行内重试入口承担 */ })
|
||||
}, [pid, filter])
|
||||
|
||||
console.log('[cockpit-dbg] RENDER inst=' + instanceId.current, 'identity=', identity, 'projects=', projects === null ? 'null' : projects.length, 'error=', error)
|
||||
if (error) return <CockpitErrorState raw={error} />
|
||||
if (!projects) return <div className="empty-note">加载中…</div>
|
||||
if (projects.length === 0) return <EmptyState icon="folder">暂无可见研发项目——项目成员身份由项目负责人授予</EmptyState>
|
||||
|
||||
Reference in New Issue
Block a user