diff --git a/web3/packages/mind-map/src/store/helpers/addCustomContentToNode.ts b/web3/packages/mind-map/src/store/helpers/addCustomContentToNode.ts index 3c064e41..7f4d791f 100644 --- a/web3/packages/mind-map/src/store/helpers/addCustomContentToNode.ts +++ b/web3/packages/mind-map/src/store/helpers/addCustomContentToNode.ts @@ -49,14 +49,10 @@ export function getCustomNodeContent() { create: (node: MindMapNode) => { // 创建包含按钮的容器 const container = document.createElement("div"); - container.style.display = "flex"; container.style.gap = `${buttonConfig.gap}px`; - - // 默认隐藏按钮组 - container.style.visibility = "hidden"; - container.style.opacity = "0"; - container.style.transition = "opacity 0.2s"; + // 默认隐藏按钮组 - 使用 display:none 节省DOM资源 + container.style.display = "none"; // 存储容器元素以便后续更新 nodeElements[node.uid] = container; @@ -66,8 +62,7 @@ export function getCustomNodeContent() { // 如果节点已激活,显示按钮组 if (node.nodeData.data.isActive) { - container.style.visibility = "visible"; - container.style.opacity = "1"; + container.style.display = "flex"; } function createButton( @@ -98,7 +93,7 @@ export function getCustomNodeContent() { btn.onclick = (e) => { e.stopPropagation(); - // const { getMindMapInstance } = useMindMapStore(); + const { getMindMapInstance } = useMindMapStore(); // 根据按钮类型执行不同操作 switch (action) { @@ -121,7 +116,8 @@ export function getCustomNodeContent() { }); break; case "edit": - + // 获取实例并编辑当前节点 + break; } }; @@ -155,8 +151,7 @@ export function getCustomNodeContent() { nodeActiveState[node.uid] = isActive; const container = nodeElements[node.uid]; if (container) { - container.style.visibility = isActive ? "visible" : "hidden"; - container.style.opacity = isActive ? "1" : "0"; + container.style.display = isActive ? "flex" : "none"; } } } @@ -175,7 +170,6 @@ export function getCustomNodeContent() { element, node, }: { - content: any; element: any; node: MindMapNode; }) => { @@ -190,8 +184,7 @@ export function getCustomNodeContent() { const isActive = node.nodeData.data.isActive || false; const container = nodeElements[node.uid]; if (container) { - container.style.visibility = isActive ? "visible" : "hidden"; - container.style.opacity = isActive ? "1" : "0"; + container.style.display = isActive ? "flex" : "none"; } }, };