feat(web): 增加循环节点的输出变量
This commit is contained in:
@@ -1,17 +1,37 @@
|
|||||||
import {Background, BackgroundVariant, type NodeProps} from '@xyflow/react'
|
import {Background, BackgroundVariant, type NodeProps} from '@xyflow/react'
|
||||||
import {classnames} from 'amis'
|
import {classnames} from 'amis'
|
||||||
import React from 'react'
|
import React, {useCallback, useEffect} from 'react'
|
||||||
import {flowBackgroundColor, flowDotColor} from '../types.ts'
|
|
||||||
import AmisNode, {nodeClassName, NormalNodeHandler} from './AmisNode.tsx'
|
|
||||||
import AddNodeButton from '../component/AddNodeButton.tsx'
|
import AddNodeButton from '../component/AddNodeButton.tsx'
|
||||||
|
import {useDataStore} from '../store/DataStore.ts'
|
||||||
|
import {flowBackgroundColor, flowDotColor} from '../types.ts'
|
||||||
|
import AmisNode, {nodeClassName, NormalNodeHandler, outputsFormColumns} from './AmisNode.tsx'
|
||||||
|
|
||||||
const LoopNode = (props: NodeProps) => {
|
const LoopNode = (props: NodeProps) => {
|
||||||
|
const {mergeDataById} = useDataStore()
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
mergeDataById(
|
||||||
|
props.id,
|
||||||
|
{
|
||||||
|
outputs: {
|
||||||
|
output: {
|
||||||
|
type: 'array-object',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
)
|
||||||
|
}, [props.id])
|
||||||
|
|
||||||
|
const columnsSchema = useCallback(() => [
|
||||||
|
...outputsFormColumns(false, true),
|
||||||
|
], [props.id])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<AmisNode
|
<AmisNode
|
||||||
className={classnames('w-full', 'h-full', nodeClassName('loop'))}
|
className={classnames('w-full', 'h-full', nodeClassName('loop'))}
|
||||||
style={{
|
style={{
|
||||||
minWidth: '350px',
|
minWidth: '350px',
|
||||||
minHeight: '290px'
|
minHeight: '290px',
|
||||||
}}
|
}}
|
||||||
nodeProps={props}
|
nodeProps={props}
|
||||||
extraNodeDescription={
|
extraNodeDescription={
|
||||||
@@ -31,6 +51,7 @@ const LoopNode = (props: NodeProps) => {
|
|||||||
<AddNodeButton className="mt-2 ml-2" parent={props.id}/>
|
<AddNodeButton className="mt-2 ml-2" parent={props.id}/>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
|
columnSchema={columnsSchema}
|
||||||
handler={<NormalNodeHandler/>}
|
handler={<NormalNodeHandler/>}
|
||||||
resize={{
|
resize={{
|
||||||
minWidth: 350,
|
minWidth: 350,
|
||||||
|
|||||||
Reference in New Issue
Block a user