fix: editor layout and SceneGraph refinements

This commit is contained in:
2026-06-14 19:57:59 +08:00
parent 681efe1d92
commit 1619c9db8b
2 changed files with 39 additions and 8 deletions

View File

@@ -7,7 +7,7 @@ import '@vue-flow/core/dist/style.css'
import '@vue-flow/controls/dist/style.css'
import '@vue-flow/core/dist/theme-default.css'
import type { Connection } from '@vue-flow/core'
import { computePositions } from '../composables/useLayout'
import { computePositions, savePosition } from '../composables/useLayout'
const props = defineProps<{
sceneNodes: { id: string; label: string }[]
@@ -24,7 +24,7 @@ const emit = defineEmits<{
const nodes = ref<any[]>([])
const edges = ref<any[]>([])
const { onNodeClick, onConnect, onNodeContextMenu, fitView } = useVueFlow()
const { onNodeClick, onConnect, onNodeContextMenu, onNodeDragStop, fitView } = useVueFlow()
const ctxMenuVisible = ref(false)
const ctxMenuX = ref(0)
const ctxMenuY = ref(0)
@@ -130,6 +130,11 @@ function closeMenu() {
ctxMenuVisible.value = false
}
onNodeDragStop((ev) => {
const pos = ev.node.position
savePosition(ev.node.id, Math.round(pos.x), Math.round(pos.y))
})
onConnect((conn: Connection) => {
if (conn.source && conn.target) emit('addEdge', conn.source, conn.target)
})