| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- /**
- * Func 功能节点逻辑
- */
- /**
- * 创建功能节点数据
- * @param {string} funcType - 功能类型
- * @param {Object} config - 节点配置
- */
- export function createFuncNodeData(funcType, config = {}) {
- const { id, label, inputs = [], outputs = [], data = {} } = config;
-
- return {
- id: id || `node_${funcType}_${Date.now()}`,
- type: funcType,
- label: label || funcType,
- inputs: [
- { id: 'input_0', label: '', type: 'execution' },
- ...inputs
- ],
- outputs: [
- { id: 'output_0', label: '', type: 'execution' },
- ...outputs
- ],
- data
- };
- }
- /**
- * 验证功能节点
- */
- export function validateFuncNode(node) {
- const errors = [];
-
- const execInput = node.inputs?.find(p => p.type === 'execution');
- const execOutput = node.outputs?.find(p => p.type === 'execution');
-
- if (!execInput) {
- errors.push('功能节点必须有执行输入端口');
- }
-
- if (!execOutput) {
- errors.push('功能节点必须有执行输出端口');
- }
-
- return {
- valid: errors.length === 0,
- errors
- };
- }
- /**
- * 功能节点转换为工作流数据
- */
- export function funcNodeToWorkflow(node) {
- return {
- type: node.type,
- data: node.data || {}
- };
- }
|