selectedKey(item, idx)"
>
diff --git a/frontend/src/views/api-test/management/components/management/mock/mockResponse.vue b/frontend/src/views/api-test/management/components/management/mock/mockResponse.vue
index ab6bfb6450..0e4203c4cd 100644
--- a/frontend/src/views/api-test/management/components/management/mock/mockResponse.vue
+++ b/frontend/src/views/api-test/management/components/management/mock/mockResponse.vue
@@ -1,9 +1,23 @@
{{ t('apiTestManagement.responseContent') }}
-
-
- {{ t('mockManagement.followDefinition') }}
+
+
+
+ {{ t('mockManagement.followDefinition') }}
+
+
-->
emit('change')"
/>
+
+ ms
+
+
+
+
+
+
+
+
+
emit('change')"
+ >
+
+ {{ ResponseBodyFormat[item].toLowerCase() }}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
{{ t('apiTestDebug.sendAsMainText') }}
+
+
+ {{ t('apiTestDebug.sendAsMainTextTip1') }}
+ {{ t('apiTestDebug.sendAsMainTextTip2') }}
+
+
+
+
+
+
+
+
emit('change')"
+ />
-
@@ -162,6 +308,7 @@
import { ResponseBodyFormat, ResponseComposition } from '@/enums/apiEnum';
import { defaultKeyValueParamItem, statusCodes } from '@/views/api-test/components/config';
+ import { filterKeyValParams } from '@/views/api-test/components/utils';
const props = defineProps<{
definitionResponses: ResponseItem[];
@@ -182,6 +329,7 @@
props.definitionResponses.map((item) => ({
label: `${t(item.label || item.name)}(${item.statusCode})`,
value: item.id,
+ defaultFlag: item.defaultFlag,
}))
);
@@ -198,6 +346,10 @@
label: t('apiTestManagement.responseCode'),
value: ResponseComposition.CODE,
},
+ {
+ label: t('mockManagement.responseDelay'),
+ value: 'DELAY',
+ },
];
const statusCodeOptions = statusCodes.map((e) => ({
@@ -300,6 +452,12 @@
}
}
+ function handleUseApiResponseChange(val: string | number | boolean) {
+ if (val) {
+ mockResponse.value.apiResponseId = (mockResponseOptions.value.find((e) => e.defaultFlag)?.value as string) || '';
+ }
+ }
+
watch(
() => mockResponse.value.body.binaryBody.file?.fileId,
() => {
@@ -312,6 +470,48 @@
immediate: true,
}
);
+
+ const currentSelectedDefinitionResponse = computed(() =>
+ props.definitionResponses.find((e) => e.id === mockResponse.value.apiResponseId)
+ );
+ const definitionActiveTab = ref(ResponseComposition.BODY);
+ // 当前显示的代码
+ const currentSelectedDefinitionBodyCode = computed({
+ get() {
+ if (currentSelectedDefinitionResponse.value?.body.bodyType === ResponseBodyFormat.JSON) {
+ return currentSelectedDefinitionResponse.value.body.jsonBody.jsonValue;
+ }
+ if (currentSelectedDefinitionResponse.value?.body.bodyType === ResponseBodyFormat.XML) {
+ return currentSelectedDefinitionResponse.value.body.xmlBody.value;
+ }
+ return currentSelectedDefinitionResponse.value?.body.rawBody.value;
+ },
+ set(val) {
+ if (
+ currentSelectedDefinitionResponse.value?.body.bodyType === ResponseBodyFormat.JSON &&
+ currentSelectedDefinitionResponse.value.body.jsonBody
+ ) {
+ currentSelectedDefinitionResponse.value.body.jsonBody.jsonValue = val || '';
+ } else if (
+ currentSelectedDefinitionResponse.value?.body.bodyType === ResponseBodyFormat.XML &&
+ currentSelectedDefinitionResponse.value.body.xmlBody
+ ) {
+ currentSelectedDefinitionResponse.value.body.xmlBody.value = val || '';
+ } else if (currentSelectedDefinitionResponse.value) {
+ currentSelectedDefinitionResponse.value.body.rawBody.value = val || '';
+ }
+ },
+ });
+ // 当前代码编辑器的语言
+ const currentSelectedDefinitionCodeLanguage = computed(() => {
+ if (currentSelectedDefinitionResponse.value?.body.bodyType === ResponseBodyFormat.JSON) {
+ return LanguageEnum.JSON;
+ }
+ if (currentSelectedDefinitionResponse.value?.body.bodyType === ResponseBodyFormat.XML) {
+ return LanguageEnum.XML;
+ }
+ return LanguageEnum.PLAINTEXT;
+ });