| 704 | }; |
| 705 | |
| 706 | const onPointerUp = () => { |
| 707 | const down = pointerDownRef.current; |
| 708 | const drag = draggingRef.current; |
| 709 | if (drag) { |
| 710 | drag.fx = null; |
| 711 | drag.fy = null; |
| 712 | sim.alphaTarget(0); |
| 713 | draggingRef.current = null; |
| 714 | canvas.style.cursor = "grab"; |
| 715 | } |
| 716 | // 单击(未拖动):点节点 = 选中并持久高亮其关联子图(再点同一个=取消); |
| 717 | // 点空白 = 取消选中。不跳转——停留在图谱页。 |
| 718 | if (down && !down.moved) { |
| 719 | const hit = pickNode(down.x, down.y); |
| 720 | selectedIdRef.current = hit ? (selectedIdRef.current === hit.id ? null : hit.id) : null; |
| 721 | cardFor(hoverIdRef.current ?? selectedIdRef.current); |
| 722 | draw(); |
| 723 | } |
| 724 | pointerDownRef.current = null; |
| 725 | }; |
| 726 | |
| 727 | // 双击节点 = 打开对应 wiki 页(保留导航能力,与单击选中互不冲突) |
| 728 | const onDblClick = (e: MouseEvent) => { |