fix(web): 不太优雅地修复循环节点初始化高度的问题

This commit is contained in:
2025-07-14 23:34:58 +08:00
parent fa06207af8
commit 0efb041c71
2 changed files with 8 additions and 13 deletions

View File

@@ -9,7 +9,7 @@ import {useFlowStore} from '../store/FlowStore.ts'
import type {ButtonProps} from 'antd/lib'
export type AddNodeButtonProps = {
parentId?: string
parent?: string
} & ButtonProps
const AddNodeButton = (props: AddNodeButtonProps) => {
@@ -25,7 +25,7 @@ const AddNodeButton = (props: AddNodeButtonProps) => {
children: NodeRegistry
.filter(i => isEqual(group, i.group))
// 循环节点里不能再嵌套循环节点
.filter(i => !props.parentId || (props.parentId && !isEqual(i.key, 'loop-node')))
.filter(i => !props.parent || (props.parent && !isEqual(i.key, 'loop-node')))
.map(i => ({key: i.key, label: i.name, icon: i.icon})),
})),
onClick: ({key}) => {
@@ -51,11 +51,11 @@ const AddNodeButton = (props: AddNodeButtonProps) => {
addNode({
id: nodeId,
type: key,
position: {x: 100, y: 130},
position: {x: 50, y: 130},
data: {},
// 如果是循环节点就将节点加入到循环节点中
...(props.parentId ? {
parentId: props.parentId,
...(props.parent ? {
parentId: props.parent,
extent: 'parent',
} : {})
})