refractor(web): 增加输入节点

This commit is contained in:
2025-07-20 17:17:22 +08:00
parent 77a09472aa
commit a5282762ed
14 changed files with 462 additions and 257 deletions

View File

@@ -5,6 +5,7 @@ import {useContextStore} from '../store/ContextStore.ts'
import {useDataStore} from '../store/DataStore.ts'
import {useFlowStore} from '../store/FlowStore.ts'
import AmisNode, {inputsFormColumns, nodeClassName, NormalNodeHandler, outputsFormColumns} from './AmisNode.tsx'
import type {FormSchema} from '../types.ts'
const languageMap: Record<string, string> = {
'javascript': 'Javascript',
@@ -19,34 +20,36 @@ const CodeNode = (props: NodeProps) => {
const nodeData = getDataById(props.id)
const columnsSchema = useCallback(() => [
...inputsFormColumns(props.id, getInputSchema(), getNodes(), getEdges(), getData()),
{
type: 'divider',
},
{
type: 'select',
name: 'type',
label: '代码类型',
required: true,
selectFirst: true,
options: Object.keys(languageMap).map(key => ({label: languageMap[key], value: key})),
},
{
type: 'editor',
required: true,
label: '代码内容',
name: 'content',
language: '${type}',
options: {
wordWrap: 'bounded',
const formSchema: () => FormSchema = useCallback(() => ({
columns: [
...inputsFormColumns(props.id, getInputSchema(), getNodes(), getEdges(), getData()),
{
type: 'divider',
},
},
{
type: 'divider',
},
...outputsFormColumns(true, false),
], [props.id])
{
type: 'select',
name: 'type',
label: '代码类型',
required: true,
selectFirst: true,
options: Object.keys(languageMap).map(key => ({label: languageMap[key], value: key})),
},
{
type: 'editor',
required: true,
label: '代码内容',
name: 'content',
language: '${type}',
options: {
wordWrap: 'bounded',
},
},
{
type: 'divider',
},
...outputsFormColumns(true, false),
]
}), [props.id])
const extraNodeDescription = useMemo(() => {
return nodeData?.type
@@ -62,7 +65,7 @@ const CodeNode = (props: NodeProps) => {
className={nodeClassName('code')}
nodeProps={props}
extraNodeDescription={extraNodeDescription}
columnSchema={columnsSchema}
formSchema={formSchema}
handler={<NormalNodeHandler/>}
/>
)