feat(web): 尝试增加并行节点解决解析问题
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
import {DeleteFilled, EditFilled} from '@ant-design/icons'
|
||||
import {Handle, type NodeProps, Position} from '@xyflow/react'
|
||||
import {Handle, type HandleProps, type NodeProps, Position, useNodeConnections} from '@xyflow/react'
|
||||
import type {Schema} from 'amis'
|
||||
import {Card, Dropdown} from 'antd'
|
||||
import {isEmpty, isEqual} from 'licia'
|
||||
import {isEmpty, isEqual, isNil} from 'licia'
|
||||
import {type JSX} from 'react'
|
||||
import {horizontalFormOptions} from '../../../../util/amis.tsx'
|
||||
|
||||
@@ -55,13 +55,26 @@ export function outputsFormColumns(editable: boolean = false, required: boolean
|
||||
]
|
||||
}
|
||||
|
||||
interface AmisNodeProps {
|
||||
nodeProps: NodeProps,
|
||||
type: AmisNodeType,
|
||||
defaultNodeName: String,
|
||||
defaultNodeDescription?: String,
|
||||
extraNodeDescription?: (nodeData: any) => JSX.Element,
|
||||
columnSchema?: Schema[],
|
||||
export const LimitHandler = (props: HandleProps & { limit: number }) => {
|
||||
const connections = useNodeConnections({
|
||||
handleType: props.type,
|
||||
})
|
||||
return (
|
||||
<Handle
|
||||
{...props}
|
||||
isConnectable={connections.length < props.limit}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
type AmisNodeProps = {
|
||||
nodeProps: NodeProps
|
||||
type: AmisNodeType
|
||||
defaultNodeName: String
|
||||
defaultNodeDescription?: String
|
||||
extraNodeDescription?: (nodeData: any) => JSX.Element
|
||||
handlers?: (nodeData: any) => JSX.Element
|
||||
columnSchema?: Schema[]
|
||||
}
|
||||
|
||||
const AmisNode: (props: AmisNodeProps) => JSX.Element = ({
|
||||
@@ -70,6 +83,7 @@ const AmisNode: (props: AmisNodeProps) => JSX.Element = ({
|
||||
defaultNodeName,
|
||||
defaultNodeDescription,
|
||||
extraNodeDescription,
|
||||
handlers,
|
||||
columnSchema,
|
||||
}) => {
|
||||
const {id, data} = nodeProps
|
||||
@@ -142,10 +156,14 @@ const AmisNode: (props: AmisNodeProps) => JSX.Element = ({
|
||||
</div>
|
||||
</Card>
|
||||
</Dropdown>
|
||||
{isEqual(type, 'start') || isEqual(type, 'normal')
|
||||
? <Handle type="source" position={Position.Right}/> : undefined}
|
||||
{isEqual(type, 'end') || isEqual(type, 'normal')
|
||||
? <Handle type="target" position={Position.Left}/> : undefined}
|
||||
{isNil(handlers)
|
||||
? <>
|
||||
{isEqual(type, 'start') || isEqual(type, 'normal')
|
||||
? <LimitHandler type="source" position={Position.Right} limit={1}/> : undefined}
|
||||
{isEqual(type, 'end') || isEqual(type, 'normal')
|
||||
? <Handle type="target" position={Position.Left}/> : undefined}
|
||||
</>
|
||||
: handlers?.(nodeData)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user