diff --git a/editor/App.vue b/editor/App.vue index 900ec57..97c77ce 100644 --- a/editor/App.vue +++ b/editor/App.vue @@ -122,6 +122,7 @@ onMounted(() => loadDemo()) @select-node="store.selectedNodeId = $event" @add-edge="editor.onAddEdge" @test-scene="testScene" + @clear-selection="store.selectedNodeId = null" />
加载剧情数据…
diff --git a/editor/components/SceneGraph.vue b/editor/components/SceneGraph.vue index 8a7f10d..df23bf6 100644 --- a/editor/components/SceneGraph.vue +++ b/editor/components/SceneGraph.vue @@ -20,11 +20,12 @@ const emit = defineEmits<{ selectNode: [id: string] addEdge: [source: string, target: string] testScene: [id: string] + clearSelection: [] }>() const nodes = ref([]) const edges = ref([]) -const { onNodeClick, onConnect, onNodeContextMenu, onNodeDragStop, fitView } = useVueFlow() +const { onNodeClick, onConnect, onNodeContextMenu, onNodeDragStop, onPaneClick, fitView } = useVueFlow() const ctxMenuVisible = ref(false) const ctxMenuX = ref(0) const ctxMenuY = ref(0) @@ -135,6 +136,8 @@ onNodeDragStop((ev) => { savePosition(ev.node.id, Math.round(pos.x), Math.round(pos.y)) }) +onPaneClick(() => emit('clearSelection')) + onConnect((conn: Connection) => { if (conn.source && conn.target) emit('addEdge', conn.source, conn.target) })