feat(web): 增加代码节点

This commit is contained in:
v-zhangjc9
2025-06-25 17:54:43 +08:00
parent 33df256863
commit 6f7f7cea67
5 changed files with 84 additions and 113 deletions

View File

@@ -0,0 +1,73 @@
import type {NodeProps} from '@xyflow/react'
import {horizontalFormOptions} from '../../../../util/amis.tsx'
import AmisNode, {outputsFormColumns} from './AmisNode.tsx'
const CodeNode = (props: NodeProps) => AmisNode(
props,
'normal',
'代码执行',
'执行自定义的处理代码',
undefined,
[
{
type: 'input-kvs',
name: 'inputs',
label: '输入变量',
addButtonText: '新增输入',
draggable: false,
keyItem: {
...horizontalFormOptions(),
label: '参数名称',
},
valueItems: [
{
...horizontalFormOptions(),
type: 'select',
name: 'type',
label: '变量',
required: true,
options: [],
},
],
},
{
type: 'divider',
},
{
type: 'select',
name: 'type',
label: '代码类型',
required: true,
options: [
{
value: 'javascript',
label: 'JavaScript',
},
{
value: 'python',
label: 'Python',
},
{
value: 'lua',
label: 'Lua',
},
],
},
{
type: 'editor',
required: true,
label: '代码内容',
name: 'content',
language: '${type}',
options: {
wordWrap: 'bounded',
},
},
{
type: 'divider',
},
...outputsFormColumns(true, true, {result: {type: 'string'}}),
],
)
export default CodeNode