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' import type {ButtonProps} from 'antd/lib'
export type AddNodeButtonProps = { export type AddNodeButtonProps = {
parentId?: string parent?: string
} & ButtonProps } & ButtonProps
const AddNodeButton = (props: AddNodeButtonProps) => { const AddNodeButton = (props: AddNodeButtonProps) => {
@@ -25,7 +25,7 @@ const AddNodeButton = (props: AddNodeButtonProps) => {
children: NodeRegistry children: NodeRegistry
.filter(i => isEqual(group, i.group)) .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})), .map(i => ({key: i.key, label: i.name, icon: i.icon})),
})), })),
onClick: ({key}) => { onClick: ({key}) => {
@@ -51,11 +51,11 @@ const AddNodeButton = (props: AddNodeButtonProps) => {
addNode({ addNode({
id: nodeId, id: nodeId,
type: key, type: key,
position: {x: 100, y: 130}, position: {x: 50, y: 130},
data: {}, data: {},
// 如果是循环节点就将节点加入到循环节点中 // 如果是循环节点就将节点加入到循环节点中
...(props.parentId ? { ...(props.parent ? {
parentId: props.parentId, parentId: props.parent,
extent: 'parent', extent: 'parent',
} : {}) } : {})
}) })

View File

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