a
This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user