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',
} : {})
})

View File

@@ -11,16 +11,11 @@ const LoopNode = (props: NodeProps) => {
className={classnames('w-full', 'h-full', nodeClassName('loop'))}
style={{
minWidth: '350px',
minHeight: '200px'
minHeight: '290px'
}}
nodeProps={props}
extraNodeDescription={
<div
className="nodrag relative h-full w-full"
style={{
minHeight: '8rem',
}}
>
<div className="nodrag relative w-full h-full" style={{minHeight: '211px'}}>
<Background
id={`loop-background-${props.id}`}
className="rounded-xl"
@@ -33,7 +28,7 @@ const LoopNode = (props: NodeProps) => {
color={flowDotColor}
bgColor={flowBackgroundColor}
/>
<AddNodeButton className="mt-2 ml-2" parentId={props.id}/>
<AddNodeButton className="mt-2 ml-2" parent={props.id}/>
</div>
}
handler={<NormalNodeHandler/>}