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)
}
}