feat(web): 增加节点输出编辑
This commit is contained in:
@@ -1,12 +1,59 @@
|
||||
import {DeleteFilled, EditFilled} from '@ant-design/icons'
|
||||
import {Handle, type NodeProps, Position} from '@xyflow/react'
|
||||
import type {Schema} from 'amis'
|
||||
import {Card, Dropdown} from 'antd'
|
||||
import {DeleteFilled, EditFilled} from '@ant-design/icons'
|
||||
import {isEmpty, isEqual} from 'licia'
|
||||
import type {JSX} from 'react'
|
||||
import {horizontalFormOptions} from '../../../../util/amis.tsx'
|
||||
|
||||
export type AmisNodeType = 'normal' | 'start' | 'end'
|
||||
|
||||
export function outputsFormColumns(editable: boolean = false, preload?: any): Schema[] {
|
||||
return [
|
||||
{
|
||||
disabled: !editable,
|
||||
type: 'input-kvs',
|
||||
name: 'outputs',
|
||||
label: '输出变量',
|
||||
value: preload,
|
||||
addButtonText: '新增输出',
|
||||
draggable: false,
|
||||
keyItem: {
|
||||
...horizontalFormOptions(),
|
||||
label: '参数名称',
|
||||
},
|
||||
valueItems: [
|
||||
{
|
||||
...horizontalFormOptions(),
|
||||
type: 'select',
|
||||
name: 'type',
|
||||
label: '参数',
|
||||
required: true,
|
||||
selectFirst: true,
|
||||
options: [
|
||||
{
|
||||
label: '文本',
|
||||
value: 'string',
|
||||
},
|
||||
{
|
||||
label: '数字',
|
||||
value: 'number',
|
||||
},
|
||||
{
|
||||
label: '文本数组',
|
||||
value: 'array-string',
|
||||
},
|
||||
{
|
||||
label: '对象数组',
|
||||
value: 'array-object',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
]
|
||||
}
|
||||
|
||||
const AmisNode = (
|
||||
props: NodeProps,
|
||||
type: AmisNodeType,
|
||||
@@ -67,10 +114,10 @@ const AmisNode = (
|
||||
placeholder: nodeDescription,
|
||||
},
|
||||
{
|
||||
type: 'divider'
|
||||
type: 'divider',
|
||||
},
|
||||
...(columnSchema ?? [])
|
||||
]
|
||||
...(columnSchema ?? []),
|
||||
],
|
||||
)
|
||||
break
|
||||
case 'remove':
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import type {NodeProps} from '@xyflow/react'
|
||||
import AmisNode from './AmisNode.tsx'
|
||||
import {horizontalFormOptions} from '../../../../util/amis.tsx'
|
||||
import AmisNode, {outputsFormColumns} from './AmisNode.tsx'
|
||||
|
||||
const EndNode = (props: NodeProps) => AmisNode(
|
||||
props,
|
||||
@@ -8,30 +7,7 @@ const EndNode = (props: NodeProps) => AmisNode(
|
||||
'结束节点',
|
||||
'定义输出变量',
|
||||
undefined,
|
||||
[
|
||||
{
|
||||
type: 'input-kvs',
|
||||
name: 'outputVariables',
|
||||
label: '输出变量',
|
||||
addButtonText: '新增输出',
|
||||
draggable: false,
|
||||
keyItem: {
|
||||
...horizontalFormOptions(),
|
||||
label: '参数名称',
|
||||
},
|
||||
valueItems: [
|
||||
{
|
||||
...horizontalFormOptions(),
|
||||
type: 'select',
|
||||
name: 'type',
|
||||
label: '参数',
|
||||
required: true,
|
||||
selectFirst: true,
|
||||
options: [],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
outputsFormColumns(true),
|
||||
)
|
||||
|
||||
export default EndNode
|
||||
@@ -1,5 +1,5 @@
|
||||
import type {NodeProps} from '@xyflow/react'
|
||||
import AmisNode from './AmisNode.tsx'
|
||||
import AmisNode, {outputsFormColumns} from './AmisNode.tsx'
|
||||
|
||||
const LlmNode = (props: NodeProps) => AmisNode(
|
||||
props,
|
||||
@@ -31,6 +31,10 @@ const LlmNode = (props: NodeProps) => AmisNode(
|
||||
label: '系统提示词',
|
||||
required: true,
|
||||
},
|
||||
{
|
||||
type: 'divider',
|
||||
},
|
||||
...outputsFormColumns(false, {text: {type: 'string'}}),
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type {NodeProps} from '@xyflow/react'
|
||||
import AmisNode from './AmisNode.tsx'
|
||||
import {horizontalFormOptions} from '../../../../util/amis.tsx'
|
||||
import AmisNode from './AmisNode.tsx'
|
||||
|
||||
const StartNode = (props: NodeProps) => AmisNode(
|
||||
props,
|
||||
@@ -11,7 +11,7 @@ const StartNode = (props: NodeProps) => AmisNode(
|
||||
[
|
||||
{
|
||||
type: 'input-kvs',
|
||||
name: 'inputVariables',
|
||||
name: 'inputs',
|
||||
label: '输入变量',
|
||||
addButtonText: '新增入参',
|
||||
draggable: false,
|
||||
|
||||
Reference in New Issue
Block a user