@@ -58,14 +58,12 @@ export const useGraphCanvas = (readonly: boolean = false): UseGraphCanvas => {
|
||||
if (graph.value) {
|
||||
clearGraph();
|
||||
|
||||
// 等待 Vue 完成卸载
|
||||
nextTick(() => {
|
||||
graph.value?.dispose(); // 销毁 Graph 实例
|
||||
graph.value = null;
|
||||
if (container.value) {
|
||||
container.value.innerHTML = ''; // 清空容器内容
|
||||
}
|
||||
});
|
||||
// 同步销毁 Graph 实例,避免异步导致的竞态条件
|
||||
graph.value.dispose();
|
||||
graph.value = null;
|
||||
if (container.value) {
|
||||
container.value.innerHTML = ''; // 清空容器内容
|
||||
}
|
||||
} else if (container.value) {
|
||||
container.value.innerHTML = '';
|
||||
}
|
||||
@@ -222,7 +220,8 @@ export const useGraphCanvas = (readonly: boolean = false): UseGraphCanvas => {
|
||||
|
||||
// 监听节点选中事件
|
||||
graph.value.on('node:selected', ({ node }) => {
|
||||
console.info('node select', node);
|
||||
console.info('node select', node,node.getData());
|
||||
|
||||
emitGraphEvent('node:selected', node);
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user