This commit is contained in:
2026-02-27 09:56:49 +08:00
parent b6af9d5044
commit a8a898d2df
9 changed files with 98 additions and 56 deletions

View File

@@ -1,3 +1,12 @@
import { createId } from '../../tools/tools'
interface NodeOptions {
id?: string
type: "InputNode" | "SecondaryNode"
class?: string
position?: { x: number, y: number }
component: any
data?: object
}
export class NodeManager {
stateManager: any
vueFlow: any
@@ -6,6 +15,22 @@ export class NodeManager {
this.vueFlow = options.vueFlow
}
nodes: [
]
createNode(options: NodeOptions) {
const id = options.id || createId()
const type = options.type || 'InputNode'
const class_ = options.class || 'custom-node'
const position = options.position || { x: 0, y: 0 }
const data = options.data || {}
data['component'] = options.component
this.stateManager.nodes.value.push({
id,
type,
class: class_,
position,
data
})
console.log(this.stateManager.nodes.value)
}
}

View File

@@ -6,6 +6,16 @@ export class StateManager {
nodes: any
edges: any
zoom: any
// 管理器
eventManager: any
flowManager: any
nodeManager: any
// 设置管理器
setManager(options) {
options.eventManager && (this.eventManager = options.eventManager)
options.flowManager && (this.flowManager = options.flowManager)
options.nodeManager && (this.nodeManager = options.nodeManager)
}
constructor(options) {
this.vueFlow = options.vueFlow
this.nodes = ref<any[]>([
@@ -87,4 +97,5 @@ export class StateManager {
this.zoom = ref(1)
}
}