This commit is contained in:
lzp
2026-03-05 11:52:06 +08:00
parent 4de16d7277
commit b45a79dd5c
4 changed files with 45 additions and 24 deletions

View File

@@ -30,7 +30,7 @@
<script setup lang="ts">
import flowCanvas from './FlowCanvas/flow-canvas.vue'
import card from './FlowCanvas/components/cards/index.vue'
import card from './FlowCanvas/components/nodes/cards/index.vue'
import { computed, ref, markRaw, onMounted, reactive, nextTick } from 'vue'
const data = reactive({
x: 100,

View File

@@ -127,7 +127,11 @@
stateManager.nodes.value = layout(
stateManager.nodes.value,
stateManager.edges.value,
direction
direction,
{
nodesep: nodeManager.nodesep,
ranksep: nodeManager.ranksep
}
)
nextTick(() => {
fitView({ maxZoom: 1 })
@@ -187,6 +191,15 @@
}
}
})
nodeManager.createResultNode({
data: {
disableDelete: true,
isHeader: false,
data: {
url: props.config.url
}
}
})
})
</script>
<style lang="less">

View File

@@ -12,6 +12,8 @@ interface NodeOptions {
export class NodeManager {
stateManager: any
vueFlow: any
nodesep = 100 // 节点间距
ranksep = 100 // 层级间距
constructor(options) {
this.stateManager = options.stateManager;
this.vueFlow = options.vueFlow
@@ -37,7 +39,7 @@ export class NodeManager {
(!snode ?
{ x: positionX, y: positionY } :
{
x: snode.position.x + snode.dimensions.width + 50 + positionX,
x: snode.position.x + snode.dimensions.width + this.nodesep + positionX,
y: snode.position.y + positionY
})
const data = options?.data || {}
@@ -100,18 +102,18 @@ export class NodeManager {
}
return this.createNode(options_)
}
copyNodeById(id: string) {
const node = this.stateManager.getNodeById(id)
const flowNode = this.stateManager.flowManager.getNodeById(id)
console.log(node,this.stateManager.flowManager.getNodeById(id))
console.log(node, this.stateManager.flowManager.getNodeById(id))
if (!node) return console.warn(`copyNodeById: ${id}找不到对应节点`)
const node_ = {
...JSON.parse(JSON.stringify(node)),
id: createId(),
position: {
x: node.position.x,
y: node.position.y + (flowNode?.dimensions?.height || 0) + 50,
y: node.position.y + (flowNode?.dimensions?.height || 0) + this.ranksep,
}
}
delete node_.data?.superiorID