72 lines
1.5 KiB
TypeScript
72 lines
1.5 KiB
TypeScript
import type {NodeProps} from '@xyflow/react'
|
|
import {horizontalFormOptions} from '../../../../util/amis.tsx'
|
|
import AmisNode, {outputsFormColumns} from './AmisNode.tsx'
|
|
|
|
const CodeNode = (props: NodeProps) => AmisNode({
|
|
nodeProps: props,
|
|
type: 'normal',
|
|
defaultNodeName: '代码执行',
|
|
defaultNodeDescription: '执行自定义的处理代码',
|
|
columnSchema: [
|
|
{
|
|
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 |