Improve graph state cleanup by fully resetting sigma instance on label change

• Modify reset logic to clear sigma instance
• Remove manual node deletion
• Update GraphLabels to use reset()
• Simplify state cleanup process
• Ensure complete graph refresh
This commit is contained in:
yangdx
2025-03-15 22:21:56 +08:00
parent 550b4d110c
commit 59ac94c61d
2 changed files with 3 additions and 17 deletions

View File

@@ -111,13 +111,8 @@ const GraphLabels = () => {
// Clear current graph data to ensure complete reload when label changes
if (newLabel !== currentLabel) {
const graphStore = useGraphStore.getState();
graphStore.clearSelection();
// Reset the graph state but preserve the instance
if (graphStore.sigmaGraph) {
const nodes = Array.from(graphStore.sigmaGraph.nodes());
nodes.forEach(node => graphStore.sigmaGraph?.dropNode(node));
}
// 完全重置图形状态
graphStore.reset();
}
if (newLabel === currentLabel && newLabel !== '*') {