diff --git a/frontend/src/views/api-test/components/executeButton.vue b/frontend/src/views/api-test/components/executeButton.vue index f17f3113c1..2fc55c4f29 100644 --- a/frontend/src/views/api-test/components/executeButton.vue +++ b/frontend/src/views/api-test/components/executeButton.vue @@ -39,6 +39,7 @@ environmentId: string; request?: (...args) => Record; isCaseDetail?: boolean; + executeCase?: boolean; }>(); const { t } = useI18n(); @@ -132,6 +133,16 @@ caseDetail.value.executeLoading = false; } + watch( + () => props.executeCase, + (val) => { + if (val === true) { + execute(isPriorityLocalExec.value ? 'localExec' : 'serverExec'); + } + }, + { immediate: true } + ); + defineExpose({ isPriorityLocalExec, execute, diff --git a/frontend/src/views/api-test/management/components/management/case/caseDetail.vue b/frontend/src/views/api-test/management/components/management/case/caseDetail.vue index 8ee391e9ef..a88b79da80 100644 --- a/frontend/src/views/api-test/management/components/management/case/caseDetail.vue +++ b/frontend/src/views/api-test/management/components/management/case/caseDetail.vue @@ -7,6 +7,7 @@ @@ -102,6 +103,7 @@ const props = defineProps<{ isDrawer?: boolean; // 抽屉 + executeCase?: boolean; detail: RequestParam; }>(); const emit = defineEmits<{ diff --git a/frontend/src/views/api-test/management/components/management/case/caseDetailDrawer.vue b/frontend/src/views/api-test/management/components/management/case/caseDetailDrawer.vue index 1c607e7d3a..8942aa721e 100644 --- a/frontend/src/views/api-test/management/components/management/case/caseDetailDrawer.vue +++ b/frontend/src/views/api-test/management/components/management/case/caseDetailDrawer.vue @@ -55,7 +55,14 @@ - + @@ -71,7 +78,8 @@ const props = defineProps<{ detail: RequestParam; - apiDetail: RequestParam; + apiDetail?: RequestParam; + executeCase?: boolean; }>(); const { t } = useI18n(); diff --git a/frontend/src/views/api-test/management/components/management/case/caseTable.vue b/frontend/src/views/api-test/management/components/management/case/caseTable.vue index a3a259e91c..133eac28e1 100644 --- a/frontend/src/views/api-test/management/components/management/case/caseTable.vue +++ b/frontend/src/views/api-test/management/components/management/case/caseTable.vue @@ -163,7 +163,7 @@ v-permission="['PROJECT_API_DEFINITION_CASE:READ+EXECUTE']" type="text" class="!mr-0" - @click="onExecute(record.id)" + @click="isApi ? openCaseDetailDrawerAndExecute(record.id) : openCaseTabAndExecute(record)" > {{ t('apiTestManagement.execute') }} @@ -265,6 +265,7 @@ v-model:visible="caseDetailDrawerVisible" :detail="caseDetail as RequestParam" :api-detail="apiDetail as RequestParam" + :execute-case="caseExecute" @update-follow="caseDetail.follow = !caseDetail.follow" @load-case="(id: string) => loadCase(id)" @delete-case="deleteCaseByDetail" @@ -418,9 +419,9 @@ offspringIds: string[]; }>(); - const emit = defineEmits<{ - (e: 'openCaseTab', record: ApiCaseDetail): void; - }>(); + const caseExecute = ref(false); + + const emit = defineEmits(['openCaseTab', 'openCaseTabAndExecute']); const appStore = useAppStore(); const { t } = useI18n(); @@ -1016,6 +1017,7 @@ } const caseDetailDrawerVisible = ref(false); + const defaultCaseParams = inject('defaultCaseParams'); const caseDetail = ref>({}); @@ -1045,6 +1047,16 @@ caseDetailDrawerVisible.value = true; } + async function openCaseDetailDrawerAndExecute(id: string) { + await getCaseDetailInfo(id); + caseExecute.value = true; + caseDetailDrawerVisible.value = true; + } + + function openCaseTabAndExecute(record: ApiCaseDetail) { + emit('openCaseTabAndExecute', record); + } + function deleteCaseByDetail() { caseDetailDrawerVisible.value = false; loadCaseList(); diff --git a/frontend/src/views/api-test/management/components/management/case/index.vue b/frontend/src/views/api-test/management/components/management/case/index.vue index 6733feb64f..6b2521dc26 100644 --- a/frontend/src/views/api-test/management/components/management/case/index.vue +++ b/frontend/src/views/api-test/management/components/management/case/index.vue @@ -1,6 +1,6 @@