diff --git a/web3/packages/mind-map/src/store/helpers/addCustomContentToNode.ts b/web3/packages/mind-map/src/store/helpers/addCustomContentToNode.ts index 7f4d791f..9cddf9d4 100644 --- a/web3/packages/mind-map/src/store/helpers/addCustomContentToNode.ts +++ b/web3/packages/mind-map/src/store/helpers/addCustomContentToNode.ts @@ -138,10 +138,11 @@ export function getCustomNodeContent() { // 监听节点激活状态变化 const { getMindMapInstance } = useMindMapStore(); + getMindMapInstance()?.on( "node_active", - (activeNode: any, activeNodeList: any[]) => { - // 检查当前节点是否在激活列表中 + (_: MindMapNode, activeNodeList: MindMapNode[]) => { + const isActive = activeNodeList.some( (activeNode) => activeNode.uid === node.uid ); @@ -150,9 +151,7 @@ export function getCustomNodeContent() { if (nodeActiveState[node.uid] !== isActive) { nodeActiveState[node.uid] = isActive; const container = nodeElements[node.uid]; - if (container) { - container.style.display = isActive ? "flex" : "none"; - } + if (container) container.style.display = isActive ? "flex" : "none"; } } ); @@ -160,8 +159,8 @@ export function getCustomNodeContent() { // 返回容器元素和预计算的尺寸 return { el: container, - width: totalWidth, // 预计算的容器总宽度 - height: buttonConfig.height, // 容器高度 + width: totalWidth, + height: buttonConfig.height, }; }, @@ -183,9 +182,7 @@ export function getCustomNodeContent() { // 初始设置按钮组显示状态 const isActive = node.nodeData.data.isActive || false; const container = nodeElements[node.uid]; - if (container) { - container.style.display = isActive ? "flex" : "none"; - } + if (container) container.style.display = isActive ? "flex" : "none"; }, }; }