This commit is contained in:
lzp
2026-03-04 15:06:22 +08:00
parent 9817e5e0db
commit cee42d8b78
28 changed files with 340 additions and 84 deletions

View File

@@ -1,3 +1,4 @@
import { TOOLS } from "./ToolManager"
export class EventManager {
stateManager: any
vueFlow: any
@@ -7,10 +8,12 @@ export class EventManager {
this.vueFlow = options.vueFlow
this.zoom = this.stateManager.zoom
}
/** 处理视口变化 */
handleViewportChange(e: any) {
const { zoom } = e
this.zoom.value = zoom
}
/** 处理节点拖动停止 */
handleNodeDragStop(e: any) {
const { node } = e
const { id, position } = node
@@ -21,4 +24,17 @@ export class EventManager {
}
})
}
/** 处理点击 */
handleClick(event: any) {
const tool = this.stateManager.tool.value
if (tool === TOOLS.TEXT) {
const { x, y, zoom } = this.vueFlow.value.viewport
const position = {
x: (event.offsetX - x) / zoom,
y: (event.offsetY - y) / zoom
}
this.stateManager.nodeManager.createTextNode({ position })
this.stateManager.toolManager.setTool(TOOLS.SELECT)
}
}
}