feat(web): 增加节点的参数展示
This commit is contained in:
@@ -1,12 +1,38 @@
|
||||
import type {NodeProps} from '@xyflow/react'
|
||||
import {Tag} from 'antd'
|
||||
import {each} from 'licia'
|
||||
import type {JSX} from 'react'
|
||||
import {horizontalFormOptions} from '../../../../util/amis.tsx'
|
||||
import AmisNode from './AmisNode.tsx'
|
||||
|
||||
const typeMap: Record<string, string> = {
|
||||
text: '文本',
|
||||
number: '数字',
|
||||
files: '文件',
|
||||
}
|
||||
|
||||
const StartNode = (props: NodeProps) => AmisNode({
|
||||
nodeProps: props,
|
||||
type: 'start',
|
||||
defaultNodeName: '开始节点',
|
||||
defaultNodeDescription: '定义输入变量',
|
||||
extraNodeDescription: nodeData => {
|
||||
const variables: JSX.Element[] = []
|
||||
const inputs = (nodeData['inputs'] ?? {}) as Record<string, { type: string, description: string }>
|
||||
each(inputs, (value, key) => {
|
||||
variables.push(
|
||||
<div className="mt-1 flex justify-between" key={key}>
|
||||
<span>{key}</span>
|
||||
<Tag className="m-0" color="blue">{typeMap[value.type]}</Tag>
|
||||
</div>,
|
||||
)
|
||||
})
|
||||
return (
|
||||
<div className="mt-2">
|
||||
{...variables}
|
||||
</div>
|
||||
)
|
||||
},
|
||||
columnSchema: [
|
||||
{
|
||||
type: 'input-kvs',
|
||||
@@ -32,20 +58,7 @@ const StartNode = (props: NodeProps) => AmisNode({
|
||||
label: '参数类型',
|
||||
required: true,
|
||||
selectFirst: true,
|
||||
options: [
|
||||
{
|
||||
label: '文本',
|
||||
value: 'text',
|
||||
},
|
||||
{
|
||||
label: '数字',
|
||||
value: 'number',
|
||||
},
|
||||
{
|
||||
label: '文件',
|
||||
value: 'files',
|
||||
},
|
||||
],
|
||||
options: Object.keys(typeMap).map(key => ({label: typeMap[key], value: key})),
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user