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 @@