| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- /**
- * Set 变量节点逻辑
- */
- /**
- * 创建 Set 节点数据
- * @param {string} varName - 变量名
- * @param {string} varType - 变量类型
- */
- export function createSetNodeData(varName, varType = 'string') {
- return {
- id: `var_set_${varName}`,
- type: 'variable',
- varMode: 'set',
- varName,
- label: varName,
- inputs: [
- { id: 'input_exec', label: '', type: 'execution' },
- { id: 'input_value', label: varName, type: 'data', paramType: varType }
- ],
- outputs: [
- { id: 'output_exec', label: '', type: 'execution' }
- ],
- data: {}
- };
- }
- /**
- * 验证 Set 节点
- */
- export function validateSetNode(node) {
- const errors = [];
-
- if (!node.varName) {
- errors.push('Set节点必须指定变量名');
- }
-
- const execInput = node.inputs?.find(p => p.type === 'execution');
- const execOutput = node.outputs?.find(p => p.type === 'execution');
- const dataInput = node.inputs?.find(p => p.type === 'data');
-
- if (!execInput) {
- errors.push('Set节点必须有执行输入端口');
- }
-
- if (!execOutput) {
- errors.push('Set节点必须有执行输出端口');
- }
-
- if (!dataInput) {
- errors.push('Set节点必须有数据输入端口');
- }
-
- return {
- valid: errors.length === 0,
- errors
- };
- }
|