From 88460d3bb12d26d35a0faa8bc99f0fcd5b5dd97b Mon Sep 17 00:00:00 2001 From: zhanghao <774378400@qq.com> Date: Tue, 14 Apr 2026 16:17:52 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20http=E8=8A=82=E7=82=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/flow.js | 49 ++++ src/views/flow/components/NodeTitle.vue | 5 +- src/views/flow/components/ParamsDrawer.vue | 254 +++++++++++++----- src/views/flow/config.js | 51 ++-- src/views/flow/index.vue | 33 ++- .../flow/nodes/common/FormItemRecursive.vue | 217 --------------- 6 files changed, 284 insertions(+), 325 deletions(-) delete mode 100644 src/views/flow/nodes/common/FormItemRecursive.vue diff --git a/src/utils/flow.js b/src/utils/flow.js index ddcced4..fb1372f 100644 --- a/src/utils/flow.js +++ b/src/utils/flow.js @@ -294,4 +294,53 @@ export const filterEmptyName = (obj) => { // 基础类型直接返回 return obj; +} + +/** + * 将原始表单配置数组 转换为 目标对象格式 + * @param {Array} source - 原始数据数组 + * @returns {Object} 转换后的目标格式对象 + */ +export const transformHttpNodeData = (source) => { + // 初始化结果对象 + const result = {}; + + // 遍历每一个顶级节点 + source.forEach(item => { + const { name, children } = item; + if (!name) return; // 过滤无name的无效节点 + + // 处理普通节点(config/headers/params):直接取 children 数组 + if (name !== 'body') { + result[name] = children || []; + return; + } + + // 专门处理 body 节点(特殊结构) + if (name === 'body') { + const bodyObj = { + type: '', + json: '', + formData: [] + }; + + // 遍历body的子项,赋值到对应字段 + children?.forEach(child => { + const childName = child.name; + if (childName === 'bodyType') { + bodyObj.type = child.input; + } + if (childName === 'json') { + bodyObj.json = child.input; + } + if (childName === 'formData') { + bodyObj.formData = child.children || []; + } + }); + + result.body = bodyObj; + } + }); + + return result; } \ No newline at end of file diff --git a/src/views/flow/components/NodeTitle.vue b/src/views/flow/components/NodeTitle.vue index 9ef336c..2d47b0d 100644 --- a/src/views/flow/components/NodeTitle.vue +++ b/src/views/flow/components/NodeTitle.vue @@ -6,9 +6,7 @@