From a294a486a3378feb8a5c7253ee5fd6b9ae7a61fb Mon Sep 17 00:00:00 2001 From: baiqi Date: Thu, 8 Feb 2024 18:01:21 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E6=8E=A5=E5=8F=A3=E6=B5=8B=E8=AF=95):=20?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E8=B0=83=E8=AF=95-=E6=A8=A1=E5=9D=97?= =?UTF-8?q?=E6=A0=91+=20header=20=E5=8F=82=E6=95=B0=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/api/modules/api-test/debug.ts | 7 ++ frontend/src/api/requrls/api-test/debug.ts | 1 + .../ms-common-script/ms-addScriptDrawer.vue | 4 +- .../business/ms-params-input/config.ts | 19 +-- .../business/ms-params-input/index.vue | 25 ++-- .../src/components/business/ms-tree/index.vue | 9 +- .../components/pure/ms-split-box/index.vue | 7 +- .../components/pure/ms-table/base-table.vue | 4 +- .../pure/ms-table/columnSelectorIcon.vue | 1 - frontend/src/enums/tableEnum.ts | 2 + frontend/src/models/apiTest/debug.ts | 82 ++++++++----- frontend/src/models/common.ts | 9 +- frontend/src/utils/index.ts | 35 +++++- .../api-test/components/apiMethodName.vue | 2 +- .../debug => components}/batchAddKeyVal.vue | 25 ++-- .../api-test/components/condition/content.vue | 2 +- .../views/api-test/components/paramTable.vue | 79 ++++++++----- .../api-test/debug/components/debug/auth.vue | 3 +- .../api-test/debug/components/debug/body.vue | 66 ++++++----- .../debug/components/debug/header.vue | 28 +++-- .../api-test/debug/components/debug/index.vue | 108 +++++++++++------- .../debug/components/debug/postcondition.vue | 7 +- .../api-test/debug/components/debug/query.vue | 10 +- .../api-test/debug/components/debug/rest.vue | 10 +- .../debug/components/debug/setting.vue | 42 ++++--- .../api-test/debug/components/moduleTree.vue | 27 ++--- frontend/src/views/api-test/debug/index.vue | 9 +- .../components/bug-detail-drawer.vue | 2 +- .../environmental/components/EnvGroupBox.vue | 4 +- .../components/allParams/index.vue | 4 +- .../components/common/TabSettingDrawer.vue | 2 +- .../components/requestHeader/index.vue | 4 +- 32 files changed, 392 insertions(+), 247 deletions(-) rename frontend/src/views/api-test/{debug/components/debug => components}/batchAddKeyVal.vue (82%) diff --git a/frontend/src/api/modules/api-test/debug.ts b/frontend/src/api/modules/api-test/debug.ts index 9b606b4bed..bdf3e3948a 100644 --- a/frontend/src/api/modules/api-test/debug.ts +++ b/frontend/src/api/modules/api-test/debug.ts @@ -4,6 +4,7 @@ import { AddDebugModuleUrl, DeleteDebugModuleUrl, ExecuteApiDebugUrl, + GetApiDebugDetailUrl, GetDebugModuleCountUrl, GetDebugModulesUrl, MoveDebugModuleUrl, @@ -13,6 +14,7 @@ import { import { AddDebugModuleParams, + DebugDetail, ExecuteRequestParams, SaveDebugParams, UpdateDebugModule, @@ -64,3 +66,8 @@ export function addDebug(data: SaveDebugParams) { export function updateDebug(data: UpdateDebugParams) { return MSR.post({ url: UpdateApiDebugUrl, data }); } + +// 获取接口调试详情 +export function getDebugDetail(id: string) { + return MSR.get({ url: GetApiDebugDetailUrl, params: id }); +} diff --git a/frontend/src/api/requrls/api-test/debug.ts b/frontend/src/api/requrls/api-test/debug.ts index 4217524b00..5a8436f3d9 100644 --- a/frontend/src/api/requrls/api-test/debug.ts +++ b/frontend/src/api/requrls/api-test/debug.ts @@ -1,6 +1,7 @@ export const ExecuteApiDebugUrl = '/api/debug/debug'; // 执行调试 export const AddApiDebugUrl = '/api/debug/add'; // 新增调试 export const UpdateApiDebugUrl = '/api/debug/update'; // 更新调试 +export const GetApiDebugDetailUrl = '/api/debug/get'; // 获取接口调试详情 export const UpdateDebugModuleUrl = '/api/debug/module/update'; // 更新模块 export const MoveDebugModuleUrl = '/api/debug/module/move'; // 移动模块 export const GetDebugModuleCountUrl = '/api/debug/module/count'; // 模块统计数量 diff --git a/frontend/src/components/business/ms-common-script/ms-addScriptDrawer.vue b/frontend/src/components/business/ms-common-script/ms-addScriptDrawer.vue index 88a722b693..7ab563a49e 100644 --- a/frontend/src/components/business/ms-common-script/ms-addScriptDrawer.vue +++ b/frontend/src/components/business/ms-common-script/ms-addScriptDrawer.vue @@ -146,8 +146,8 @@ }, { title: 'project.commonScript.description', - slotName: 'desc', - dataIndex: 'desc', + slotName: 'description', + dataIndex: 'description', }, { title: 'project.commonScript.isRequired', diff --git a/frontend/src/components/business/ms-params-input/config.ts b/frontend/src/components/business/ms-params-input/config.ts index 1d749e00bf..33007f6f91 100644 --- a/frontend/src/components/business/ms-params-input/config.ts +++ b/frontend/src/components/business/ms-params-input/config.ts @@ -166,13 +166,6 @@ export const mockStringGroup: MockParamItem[] = [ ], }, ]; -// 字符串变量特殊处理 -export const specialStringVars = [ - '@character(pool)', - "@character('lower')", - "@character('upper')", - "@character('symbol')", -]; // mock日期分组 export const mockDateGroup: MockParamItem[] = [ { @@ -901,3 +894,15 @@ export const JMeterAllVars = [ ...JMeterInfoGroup, ...JMeterStringGroup, ]; +// 同名函数但参数不同,需要特殊处理 +export const sameFuncNameVars = [ + '@character(pool)', + "@character('lower')", + "@character('upper')", + "@character('symbol')", + '@idCard(birth)', + '@natural(1,100)', + '@integer(1,100)', +]; +// 带形参的函数集合,指的是函数入参为形参,如果用户未填写实参则不需要填充到入参框中 +export const formalParameterVars = ['@character(pool)', '@idCard(birth)']; diff --git a/frontend/src/components/business/ms-params-input/index.vue b/frontend/src/components/business/ms-params-input/index.vue index 4d4d5aa1db..e46250e661 100644 --- a/frontend/src/components/business/ms-params-input/index.vue +++ b/frontend/src/components/business/ms-params-input/index.vue @@ -238,12 +238,13 @@ import { useI18n } from '@/hooks/useI18n'; import { + formalParameterVars, JMeterAllGroup, JMeterAllVars, mockAllGroup, mockAllParams, mockFunctions, - specialStringVars, + sameFuncNameVars, } from './config'; import type { MockParamInputGroupItem, MockParamItem } from './types'; import type { AutoComplete, CascaderOption, FormInstance } from '@arco-design/web-vue'; @@ -375,7 +376,8 @@ // 匹配@开头的函数名 const regex = /@([a-zA-Z]+)(\([^)]*\))?/; const currentParamType = mockAllParams.find((e) => { - if (specialStringVars.includes(val)) { + if (sameFuncNameVars.includes(val)) { + // 如果是同名函数,但可能是不同的变量,所以需要全等匹配 return e.value === val; } if (e.value.match(regex)?.[1] === val.match(regex)?.[1]) { @@ -428,6 +430,7 @@ */ function openParamSetting() { if (/^\$/.test(innerValue.value)) { + // 如果是 JMeter 变量 paramSettingType.value = 'jmeter'; if (JMeterAllVars.findIndex((e) => e.value === innerValue.value) !== -1) { paramForm.value.JMeterType = innerValue.value; @@ -435,6 +438,7 @@ paramForm.value.JMeterType = ''; } } else if (/^@/.test(innerValue.value)) { + // 如果是 Mock 变量 const valueArr = innerValue.value.split('|'); // 分割 mock变量和函数 if (valueArr[0]) { // 匹配@开头的变量名 @@ -444,16 +448,23 @@ if (variableMatch) { const variableName = variableMatch[1]; const variableParams = variableMatch[2]?.split(',').map((param) => param.trim()); + const formalParameterVar = formalParameterVars.find((e) => e.includes(variableName)); // 匹配带形参的函数,监测输入的变量是否是带形参的函数 - if (variableName === 'character') { - handleParamTypeChange(`@${variableName}(${variableParams})`); // character变量特殊处理 + if (formalParameterVar && variableParams.length > 0) { + // 如果是带形参的函数,则需要使用 原函数名(形式参数) 的变量 + handleParamTypeChange(formalParameterVar); + } else if (sameFuncNameVars.includes(valueArr[0])) { + // 如果是同名函数,但可能是不同的变量,所以需要全等匹配 + handleParamTypeChange(valueArr[0]); } else { handleParamTypeChange(`@${variableName}`); // 设置匹配的变量参数输入框组 } - if (variableName !== 'character' || (variableName === 'character' && variableParams?.[0] !== 'pool')) { - // 字符串变量@character(pool)特殊处理,不需要填入 pool + if (!formalParameterVars.includes(valueArr[0])) { + // 如果是带形式参数的函数,且未填实参,则不需要填入参数 + // 如果是带形式参数的函数,但已填写实参,则需要填入参数 + // 如果是非形式参数的函数,则需要填入参数 (variableParams || []).forEach((e, i) => { - // 设置变量入参 + // 根据入参顺序,设置变量入参 paramForm.value[`param${i + 1}`] = Number.isNaN(Number(e)) ? e : Number(e); }); } diff --git a/frontend/src/components/business/ms-tree/index.vue b/frontend/src/components/business/ms-tree/index.vue index cdcf555549..dc363990df 100644 --- a/frontend/src/components/business/ms-tree/index.vue +++ b/frontend/src/components/business/ms-tree/index.vue @@ -470,9 +470,12 @@ } } } - } - .arco-tree-node-disabled-selectable { - @apply !cursor-default; + .arco-tree-node-disabled-selectable { + @apply cursor-default; + .arco-tree-node-title { + @apply cursor-default; + } + } } } diff --git a/frontend/src/components/pure/ms-split-box/index.vue b/frontend/src/components/pure/ms-split-box/index.vue index 865079cf3a..e97772bf07 100644 --- a/frontend/src/components/pure/ms-split-box/index.vue +++ b/frontend/src/components/pure/ms-split-box/index.vue @@ -16,7 +16,7 @@
diff --git a/frontend/src/views/api-test/debug/components/debug/header.vue b/frontend/src/views/api-test/debug/components/debug/header.vue index 039febda14..d64b30eedf 100644 --- a/frontend/src/views/api-test/debug/components/debug/header.vue +++ b/frontend/src/views/api-test/debug/components/debug/header.vue @@ -1,14 +1,14 @@