diff --git a/frontend/src/api/modules/api-test/scenario.ts b/frontend/src/api/modules/api-test/scenario.ts index 6178561558..753fbccbed 100644 --- a/frontend/src/api/modules/api-test/scenario.ts +++ b/frontend/src/api/modules/api-test/scenario.ts @@ -14,6 +14,7 @@ import { DeleteScenarioUrl, ExecuteHistoryUrl, ExecuteScenarioUrl, + FollowScenarioUrl, GetModuleCountUrl, GetModuleTreeUrl, GetScenarioStepUrl, @@ -238,3 +239,8 @@ export function executeScenario(data: ApiScenarioDebugRequest) { export function getSystemRequest(data: GetSystemRequestParams) { return MSR.post({ url: GetSystemRequestUrl, data }); } + +// 关注/取消关注接口场景 +export function followScenario(id: string | number) { + return MSR.get({ url: FollowScenarioUrl, params: id }); +} diff --git a/frontend/src/api/requrls/api-test/scenario.ts b/frontend/src/api/requrls/api-test/scenario.ts index 3e7fb80930..c4fb2f4de7 100644 --- a/frontend/src/api/requrls/api-test/scenario.ts +++ b/frontend/src/api/requrls/api-test/scenario.ts @@ -16,6 +16,7 @@ export const ScenarioTransferModuleOptionsUrl = '/api/scenario/transfer/options' export const DebugScenarioUrl = '/api/scenario/debug'; // 接口场景调试(不保存报告) export const ExecuteScenarioUrl = '/api/scenario/run'; // 接口场景执行(保存报告) export const GetSystemRequestUrl = '/api/scenario/get/system-request'; // 获取导入的系统请求数据 +export const FollowScenarioUrl = '/api/scenario/follow'; // 关注/取消关注接口场景 export const BatchRecycleScenarioUrl = '/api/scenario/batch-operation/delete-gc'; // 批量删除接口场景 export const BatchMoveScenarioUrl = '/api/scenario/batch-operation/move'; // 批量移动接口场景 export const BatchCopyScenarioUrl = '/api/scenario/batch-operation/copy'; // 批量复制接口场景 diff --git a/frontend/src/views/api-test/scenario/components/common/customApiDrawer.vue b/frontend/src/views/api-test/scenario/components/common/customApiDrawer.vue index 5332e0b009..0b5e9ce359 100644 --- a/frontend/src/views/api-test/scenario/components/common/customApiDrawer.vue +++ b/frontend/src/views/api-test/scenario/components/common/customApiDrawer.vue @@ -82,14 +82,18 @@ + > + +
@@ -128,6 +132,7 @@
+ requestVModel.value.customizeRequestEnvEnable && + currentEnvConfig?.value.httpConfig.find((e) => e.type === 'NONE')?.url + ); watch( () => props.stepResponses, @@ -1007,7 +1017,7 @@ } requestVModel.value = { executeLoading: false, - activeTab: res.protocol === 'HTTP' ? RequestComposition.HEADER : RequestComposition.PLUGIN, + activeTab: contentTabList.value[0].value, unSaved: false, isNew: false, label: res.name, @@ -1018,6 +1028,7 @@ name: res.name, // request里面还有个name但是是null resourceId: res.id, stepId: props.step?.id || '', + responseActiveTab: ResponseComposition.BODY, ...parseRequestBodyResult, }; if (_stepType.value.isQuoteApi && props.request && isHttpProtocol.value) { @@ -1050,8 +1061,8 @@ } } nextTick(() => { - requestVModel.value.activeTab = contentTabList.value[0].value; // 等待内容渲染出来再隐藏loading + requestVModel.value.activeTab = contentTabList.value[0].value; loading.value = false; }); } catch (error) { @@ -1073,6 +1084,8 @@ requestVModel.value = cloneDeep({ ...defaultApiParams, ...props.request, + activeTab: contentTabList.value[0].value, + responseActiveTab: ResponseComposition.BODY, isNew: false, }); if (_stepType.value.isQuoteApi) { diff --git a/frontend/src/views/api-test/scenario/components/common/importApiDrawer/index.vue b/frontend/src/views/api-test/scenario/components/common/importApiDrawer/index.vue index d4b18f8107..6711192a11 100644 --- a/frontend/src/views/api-test/scenario/components/common/importApiDrawer/index.vue +++ b/frontend/src/views/api-test/scenario/components/common/importApiDrawer/index.vue @@ -261,6 +261,7 @@ ...node, copyFromStepId: node.id, config: { + ...node.config, isRefScenarioStep: true, // 默认是完全引用的 }, id: getGenerateId(), diff --git a/frontend/src/views/api-test/scenario/components/scenarioTable.vue b/frontend/src/views/api-test/scenario/components/scenarioTable.vue index 64972d5766..6e8401ac7c 100644 --- a/frontend/src/views/api-test/scenario/components/scenarioTable.vue +++ b/frontend/src/views/api-test/scenario/components/scenarioTable.vue @@ -131,7 +131,7 @@ v-permission="['PROJECT_API_SCENARIO:READ+EXECUTE']" type="text" class="!mr-0" - @click="openScenarioTab(record)" + @click="openScenarioTab(record, 'execute')" > {{ t('apiScenario.execute') }} @@ -140,7 +140,7 @@ v-permission="['PROJECT_API_SCENARIO:READ+ADD']" type="text" class="!mr-0" - @click="openScenarioTab(record, true)" + @click="openScenarioTab(record, 'copy')" > {{ t('common.copy') }} @@ -353,7 +353,7 @@ readOnly?: boolean; // 是否是只读模式 }>(); const emit = defineEmits<{ - (e: 'openScenario', record: ApiScenarioTableItem, isCopy?: boolean): void; + (e: 'openScenario', record: ApiScenarioTableItem, action?: 'copy' | 'execute'): void; (e: 'refreshModuleTree', params: any): void; }>(); @@ -943,8 +943,8 @@ } } - function openScenarioTab(record: ApiScenarioTableItem, isCopy = false) { - emit('openScenario', record, isCopy); + function openScenarioTab(record: ApiScenarioTableItem, action?: 'copy' | 'execute') { + emit('openScenario', record, action); } defineExpose({ diff --git a/frontend/src/views/api-test/scenario/components/step/stepTree.vue b/frontend/src/views/api-test/scenario/components/step/stepTree.vue index 1f15ea328a..b332b3f9f5 100644 --- a/frontend/src/views/api-test/scenario/components/step/stepTree.vue +++ b/frontend/src/views/api-test/scenario/components/step/stepTree.vue @@ -325,10 +325,18 @@ {{ t('apiScenario.sourceScenario') }} - + {{ t('apiScenario.empty') }} - {{ t('apiScenario.sourceScenarioEnv') }} + + {{ + t( + scenarioConfigForm.useCurrentScenarioParam + ? 'apiScenario.sourceScenarioParams' + : 'apiScenario.currentScenarioParams' + ) + }} + @@ -352,11 +360,8 @@
{{ t('apiScenario.valuePriority') }}
-
- {{ t('apiScenario.currentScenarioAndNull') }} -
-
- {{ t('apiScenario.sourceScenarioAndNull') }} +
+ {{ scenarioConfigParamTip }}
@@ -614,7 +619,74 @@ useCurrentScenarioParam: true, }); const showScenarioConfig = ref(false); + const scenarioConfigParamTip = computed(() => { + if ( + scenarioConfigForm.value.useCurrentScenarioParam && + !scenarioConfigForm.value.useBothScenarioParam && + !scenarioConfigForm.value.enableScenarioEnv + ) { + // 使用当前场景参数-空值 + return t('apiScenario.currentScenarioAndNull'); + } + if ( + scenarioConfigForm.value.useCurrentScenarioParam && + !scenarioConfigForm.value.useBothScenarioParam && + scenarioConfigForm.value.enableScenarioEnv + ) { + // 使用当前场景参数-空值-且选择源场景环境 + return t('apiScenario.currentScenarioAndNullAndSourceEnv'); + } + if ( + scenarioConfigForm.value.useCurrentScenarioParam && + scenarioConfigForm.value.useBothScenarioParam && + !scenarioConfigForm.value.enableScenarioEnv + ) { + // 使用当前场景参数-原场景参数 + return t('apiScenario.currentScenarioAndSourceScenario'); + } + if ( + scenarioConfigForm.value.useCurrentScenarioParam && + scenarioConfigForm.value.useBothScenarioParam && + scenarioConfigForm.value.enableScenarioEnv + ) { + // 使用当前场景参数-原场景参数-且选择源场景环境 + return t('apiScenario.currentScenarioAndSourceScenarioAndSourceEnv'); + } + if ( + !scenarioConfigForm.value.useCurrentScenarioParam && + !scenarioConfigForm.value.useBothScenarioParam && + !scenarioConfigForm.value.enableScenarioEnv + ) { + // 使用原场景参数-空值 + return t('apiScenario.sourceScenarioAndNull'); + } + if ( + !scenarioConfigForm.value.useCurrentScenarioParam && + !scenarioConfigForm.value.useBothScenarioParam && + scenarioConfigForm.value.enableScenarioEnv + ) { + // 使用原场景参数-空值-且选择源场景环境 + return t('apiScenario.sourceScenarioAndNullAndSourceEnv'); + } + if ( + !scenarioConfigForm.value.useCurrentScenarioParam && + scenarioConfigForm.value.useBothScenarioParam && + !scenarioConfigForm.value.enableScenarioEnv + ) { + // 使用原场景参数-当前场景参数 + return t('apiScenario.sourceScenarioAndCurrentScenario'); + } + if ( + !scenarioConfigForm.value.useCurrentScenarioParam && + scenarioConfigForm.value.useBothScenarioParam && + scenarioConfigForm.value.enableScenarioEnv + ) { + // 使用原场景参数-当前场景参数-且选择源场景环境 + return t('apiScenario.sourceScenarioAndCurrentScenarioAndSourceEnv'); + } + }); + // 关闭场景配置弹窗 function cancelScenarioConfig() { showScenarioConfig.value = false; scenarioConfigForm.value = { @@ -625,11 +697,12 @@ }; } + // 应用场景配置 function saveScenarioConfig() { if (activeStep.value) { const realStep = findNodeByKey(steps.value, activeStep.value.id, 'id'); if (realStep) { - realStep.refType = scenarioConfigForm.value.refType; + realStep.refType = scenarioConfigForm.value.refType; // 更新场景引用类型 realStep.config = { ...realStep.config, ...scenarioConfigForm.value, @@ -1443,7 +1516,7 @@ .arco-tree-node-title { @apply !cursor-pointer bg-white; - padding: 12px 4px; + padding: 8px 4px; &:hover { background-color: var(--color-text-n9) !important; } diff --git a/frontend/src/views/api-test/scenario/detail/index.vue b/frontend/src/views/api-test/scenario/detail/index.vue index 1303754017..b4ac41b519 100644 --- a/frontend/src/views/api-test/scenario/detail/index.vue +++ b/frontend/src/views/api-test/scenario/detail/index.vue @@ -1,7 +1,7 @@