@@ -41,14 +41,17 @@ export default function NoteLinkToSystem({ noteId, onChanged }: Props) {
4141 ) ;
4242 const links = linkGroups . flat ( ) ;
4343 setLinked ( links . find ( ( l ) => l . targetType === "note" && l . targetId === noteId ) ?? null ) ;
44+ setErr ( "" ) ; // 成功后清掉陈旧错误(审查修复)
4445 } catch ( e ) { setErr ( `体系加载失败: ${ e } ` ) ; }
4546 } , [ noteId ] ) ;
4647
4748 useEffect ( ( ) => { void load ( ) ; } , [ load ] ) ;
4849
49- // 选体系后拉取该体系节点树
50+ // 选体系后拉取该体系节点树(体系一变即重置节点选择——
51+ // 防残留 nodeId 串体系被后端拒「引用实体不属于该体系」,审查修复)
5052 useEffect ( ( ) => {
51- if ( systemId == null ) { setNodes ( [ ] ) ; setNodeId ( null ) ; return ; }
53+ setNodeId ( null ) ;
54+ if ( systemId == null ) { setNodes ( [ ] ) ; return ; }
5255 invoke < KnowledgeNode [ ] > ( "list_knowledge_nodes" , { systemId } )
5356 . then ( setNodes )
5457 . catch ( ( e ) => setErr ( `节点加载失败: ${ e } ` ) ) ;
@@ -87,7 +90,7 @@ export default function NoteLinkToSystem({ noteId, onChanged }: Props) {
8790 const linkedSystem = systems . find ( ( s ) => s . id === linked ?. systemId ) ?? null ;
8891
8992 return (
90- < span style = { { display : "inline-flex" , flexDirection : "column" , alignItems : "flex-start" , gap : 4 } } >
93+ < span style = { { display : "inline-flex" , flexDirection : "column" , alignItems : "flex-start" , gap : 4 , position : "relative" } } >
9194 < button
9295 data-testid = "note-link-open"
9396 onClick = { ( ) => setOpen ( ( v ) => ! v ) }
@@ -129,7 +132,7 @@ export default function NoteLinkToSystem({ noteId, onChanged }: Props) {
129132 style = { { fontSize : 12 , padding : "4px 6px" , border : "1px solid #e5e7eb" , borderRadius : 4 } }
130133 disabled = { effectiveSystemId == null }
131134 >
132- < option value = "" > 挂到体系根(不选节点) </ option >
135+ < option value = "" > 选择节点… </ option >
133136 { nodes . map ( ( n ) => (
134137 < option key = { n . id } value = { n . id } > { n . text . slice ( 0 , 24 ) } </ option >
135138 ) ) }
@@ -147,7 +150,7 @@ export default function NoteLinkToSystem({ noteId, onChanged }: Props) {
147150 < button
148151 data-testid = "note-link-confirm"
149152 onClick = { ( ) => void confirmLink ( ) }
150- disabled = { busy || effectiveSystemId == null }
153+ disabled = { busy || effectiveSystemId == null || nodeId == null }
151154 style = { { fontSize : 12 , cursor : "pointer" , padding : "4px 0" , borderRadius : 4 , border : "1px solid #0f766e" , background : "#f0fdfa" , color : "#0f766e" } }
152155 >
153156 { busy ? "挂接中…" : "确认挂接" }
0 commit comments