From ce9811329d2a83e5a929555bd4dd1e7be4c2b9d4 Mon Sep 17 00:00:00 2001 From: baiqi Date: Wed, 27 Mar 2024 22:44:33 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E6=8E=A5=E5=8F=A3=E5=9C=BA=E6=99=AF):=20?= =?UTF-8?q?=E5=9C=BA=E6=99=AF=E9=85=8D=E7=BD=AE&=E5=9C=BA=E6=99=AF?= =?UTF-8?q?=E6=8B=96=E6=8B=BD&=E5=9C=BA=E6=99=AF=E5=90=AF=E7=94=A8?= =?UTF-8?q?=E7=A6=81=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/assets/style/arco-reset.less | 13 +- .../src/components/pure/ms-table/useTable.ts | 7 + frontend/src/enums/apiEnum.ts | 2 +- frontend/src/models/apiTest/scenario.ts | 14 +- .../components/common/customApiDrawer.vue | 19 +- .../components/common/customCaseDrawer.vue | 859 ++++++++++++++++-- .../common/importApiDrawer/index.vue | 31 +- .../common/importApiDrawer/table.vue | 12 +- .../api-test/scenario/components/config.ts | 10 +- .../step/createAction/useCreateActions.ts | 8 +- .../scenario/components/step/index.vue | 3 +- .../scenario/components/step/stepTree.vue | 184 +++- .../src/views/api-test/scenario/index.vue | 3 +- .../views/api-test/scenario/locale/zh-CN.ts | 15 + .../system/config/components/baseConfig.vue | 5 +- 15 files changed, 1052 insertions(+), 133 deletions(-) diff --git a/frontend/src/assets/style/arco-reset.less b/frontend/src/assets/style/arco-reset.less index 15fa68ea8c..1fa92ed83a 100644 --- a/frontend/src/assets/style/arco-reset.less +++ b/frontend/src/assets/style/arco-reset.less @@ -468,7 +468,6 @@ } } } - .arco-radio-checked:not(.arco-radio-disabled) { .arco-radio-icon { @apply !bg-white; @@ -596,7 +595,6 @@ .ms-container { height: calc(100vh - 84px); } - .ms-form { .arco-form-item { margin-bottom: 16px; @@ -616,18 +614,19 @@ height: 14px; } } + margin-right: 24px; } .arco-radio-group-button { padding: 1px; background-color: var(--color-text-n8); .arco-radio-button { - @apply bg-transparent; + @apply bg-transparent; margin: 1px; } .arco-radio-checked { - @apply bg-white; + @apply bg-white; color: rgb(var(--primary-5)); } @@ -643,7 +642,8 @@ } .arco-radio-checked:not(.arco-radio-disabled) { .arco-radio-icon { - @apply !bg-white; + @apply !bg-white; + width: 16px; height: 16px; line-height: 16px; @@ -658,11 +658,8 @@ } } } - } - - /** 气泡弹窗 **/ .arco-popover-title { font-size: 14px; diff --git a/frontend/src/components/pure/ms-table/useTable.ts b/frontend/src/components/pure/ms-table/useTable.ts index 6a990e424a..23aa635fe0 100644 --- a/frontend/src/components/pure/ms-table/useTable.ts +++ b/frontend/src/components/pure/ms-table/useTable.ts @@ -312,6 +312,12 @@ export default function useTableProps( } }; + // 重置筛选 + const clearSelector = () => { + propsRes.value.selectorStatus = SelectAllEnum.NONE; // 重置选择器状态 + resetSelector(); + }; + // 获取当前表格的选中项数量 const getSelectedCount = () => { const { selectorStatus, msPagination, excludeKeys, selectedKeys } = propsRes.value; @@ -472,6 +478,7 @@ export default function useTableProps( setAdvanceFilter, resetPagination, getSelectedCount, + clearSelector, resetSelector, getTableQueryParams, setTableSelected, diff --git a/frontend/src/enums/apiEnum.ts b/frontend/src/enums/apiEnum.ts index 43f640bf15..4226e500d7 100644 --- a/frontend/src/enums/apiEnum.ts +++ b/frontend/src/enums/apiEnum.ts @@ -255,7 +255,7 @@ export enum ScenarioStepType { LOOP_CONTROLLER = 'LOOP_CONTROLLER', // 循环控制器 API = 'API', // 接口定义 CUSTOM_REQUEST = 'CUSTOM_REQUEST', // 自定义请求 - API_SCENARIO = ' API_SCENARIO', // 场景 + API_SCENARIO = 'API_SCENARIO', // 场景 IF_CONTROLLER = 'IF_CONTROLLER', // 条件控制器 ONCE_ONLY_CONTROLLER = 'ONCE_ONLY_CONTROLLER', // 一次控制器 CONSTANT_TIMER = 'CONSTANT_TIMER', // 等待控制器 diff --git a/frontend/src/models/apiTest/scenario.ts b/frontend/src/models/apiTest/scenario.ts index 7b55f00cb7..c3ca7b4649 100644 --- a/frontend/src/models/apiTest/scenario.ts +++ b/frontend/src/models/apiTest/scenario.ts @@ -298,8 +298,20 @@ export interface LoopStepDetail extends StepDetailsCommon { msCountController: CountController; whileController: WhileController; } +export interface ScenarioStepConfig { + useCurrentScenarioParam: boolean; // 是否优先使用当前场景参数 + useBothScenarioParam: boolean; // 是否当前场景参数和源场景参数都应用(勾选非空值时为 true) + enableScenarioEnv: boolean; // 是否应用源场景环境 +} export type ScenarioStepDetail = Partial< - CustomApiStepDetail & ConditionStepDetail & LoopStepDetail & { protocol: string; method: RequestMethods } + CustomApiStepDetail & + ConditionStepDetail & + LoopStepDetail & + ScenarioStepConfig & { + protocol: string; + method: RequestMethods; + isRefScenarioStep?: boolean; // 是否是完全引用的场景下的步骤,是的话不允许启用禁用 + } >; export interface ScenarioStepItem { id: string | number; 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 6a8a0f4395..4d11d10ac9 100644 --- a/frontend/src/views/api-test/scenario/components/common/customApiDrawer.vue +++ b/frontend/src/views/api-test/scenario/components/common/customApiDrawer.vue @@ -260,7 +260,6 @@ :is-expanded="isVerticalExpanded" :request-result="props.stepResponses?.[requestVModel.stepId]" :console="props.stepResponses?.[requestVModel.stepId]?.console" - :show-empty="false" :is-edit="false" is-definition :loading="requestVModel.executeLoading || loading" @@ -362,6 +361,7 @@ export type RequestParam = ExecuteApiRequestFullParams & { response?: RequestTaskResult; + customizeRequest?: boolean; customizeRequestEnvEnable?: boolean; } & RequestCustomAttr; @@ -395,11 +395,12 @@ const visible = defineModel('visible', { required: true }); const loading = defineModel('detailLoading', { default: false }); - const defaultDebugParams: RequestParam = { + const defaultApiParams: RequestParam = { name: '', type: 'api', stepId: '', resourceId: '', + customizeRequest: true, customizeRequestEnvEnable: false, protocol: 'HTTP', url: '', @@ -455,7 +456,7 @@ executeLoading: false, }; - const requestVModel = ref(defaultDebugParams); + const requestVModel = ref(defaultApiParams); const _stepType = computed(() => { if (props.step) { return getStepType(props.step); @@ -832,7 +833,9 @@ if (val) { verticalSplitBoxRef.value?.expand(0.6); } else { - verticalSplitBoxRef.value?.collapse(1); + verticalSplitBoxRef.value?.collapse( + splitContainerRef.value ? `${splitContainerRef.value.clientHeight - 42}px` : 0 + ); } } @@ -843,7 +846,8 @@ if (val) { changeVerticalExpand(true); } else { - changeVerticalExpand(false); + isVerticalExpanded.value = false; + verticalSplitBoxRef.value?.collapse(1); } }); } @@ -931,6 +935,7 @@ protocol: requestVModel.value.protocol, method: isHttpProtocol.value ? requestVModel.value.method : requestVModel.value.protocol, name: requestVModel.value.name, + customizeRequest: props.step?.stepType === ScenarioStepType.CUSTOM_REQUEST || !props.request, customizeRequestEnvEnable: requestVModel.value.customizeRequestEnvEnable, children: [ { @@ -1066,7 +1071,7 @@ if (props.request) { // 查看自定义请求、引用 api、复制 api requestVModel.value = cloneDeep({ - ...defaultDebugParams, + ...defaultApiParams, ...props.request, isNew: false, }); @@ -1082,7 +1087,7 @@ } else { // 新建自定义请求 requestVModel.value = cloneDeep({ - ...defaultDebugParams, + ...defaultApiParams, stepId: getGenerateId(), }); } diff --git a/frontend/src/views/api-test/scenario/components/common/customCaseDrawer.vue b/frontend/src/views/api-test/scenario/components/common/customCaseDrawer.vue index 71b8705fc4..bf4eb0eb7d 100644 --- a/frontend/src/views/api-test/scenario/components/common/customCaseDrawer.vue +++ b/frontend/src/views/api-test/scenario/components/common/customCaseDrawer.vue @@ -40,73 +40,303 @@ -
- - + + + +
+
+
+
+ +
+ + +
{{ requestVModel.name }}
+
+
+ + + + +
+
+ + {{ isPriorityLocalExec ? t('apiTestDebug.localExec') : t('apiTestDebug.serverExec') }} + + + + + {{ t('apiTestDebug.serverExec') }} + + {{ t('common.stop') }} +
+
+ +
+
+ +
+
+ + + + +
-