From 2ad6cc78d09d2caeb2c644fc62b6678d2dbc5da5 Mon Sep 17 00:00:00 2001 From: baiqi Date: Mon, 2 Sep 2024 17:40:31 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E6=8E=A5=E5=8F=A3=E6=B5=8B=E8=AF=95):=20c?= =?UTF-8?q?url=E5=AF=BC=E5=85=A5=E8=A7=A3=E6=9E=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/api/modules/api-test/common.ts | 7 + frontend/src/api/requrls/api-test/common.ts | 1 + frontend/src/models/apiTest/common.ts | 8 + .../api-test/components/importCurlDialog.vue | 82 +++ frontend/src/views/api-test/debug/index.vue | 61 +- .../components/common/customApiDrawer.vue | 671 +++++++++--------- 6 files changed, 464 insertions(+), 366 deletions(-) create mode 100644 frontend/src/views/api-test/components/importCurlDialog.vue diff --git a/frontend/src/api/modules/api-test/common.ts b/frontend/src/api/modules/api-test/common.ts index 2dff888d28..71ebf51aeb 100644 --- a/frontend/src/api/modules/api-test/common.ts +++ b/frontend/src/api/modules/api-test/common.ts @@ -5,12 +5,14 @@ import { GetPluginOptionsUrl, GetPluginScriptUrl, GetProtocolListUrl, + ImportCurlUrl, LocalExecuteApiDebugUrl, StopExecuteUrl, StopLocalExecuteUrl, } from '@/api/requrls/api-test/common'; import { + type CurlParseResult, ExecuteRequestParams, GetPluginOptionsParams, PluginConfig, @@ -61,3 +63,8 @@ export function stopLocalExecute(host: string, id: string | number, type?: Scena export function stopExecute(id: string | number, type?: ScenarioStepType) { return MSR.get({ url: type ? `${StopExecuteUrl}/${type}/${id}` : `${StopExecuteUrl}/${id}` }); } + +// 导入curl +export function importByCurl(curl: string) { + return MSR.post({ url: ImportCurlUrl, data: { curl } }); +} diff --git a/frontend/src/api/requrls/api-test/common.ts b/frontend/src/api/requrls/api-test/common.ts index d7210ba818..43571388ff 100644 --- a/frontend/src/api/requrls/api-test/common.ts +++ b/frontend/src/api/requrls/api-test/common.ts @@ -6,3 +6,4 @@ export const GetEnvListUrl = '/api/test/env-list'; // 获取接口测试环境 export const GetEnvironmentUrl = '/api/test/environment'; // 获取接口测试环境详情 export const StopExecuteUrl = '/task/center/api/project/stop'; // 停止执行 export const StopLocalExecuteUrl = '/api/stop'; // 停止本地执行 +export const ImportCurlUrl = '/api/debug/import-curl'; // 导入curl diff --git a/frontend/src/models/apiTest/common.ts b/frontend/src/models/apiTest/common.ts index 753b91ada6..9fb2442614 100644 --- a/frontend/src/models/apiTest/common.ts +++ b/frontend/src/models/apiTest/common.ts @@ -463,3 +463,11 @@ export type ApiCaseReportDetail = { scriptIdentifier: string; content: RequestResult; }; +// curl解析结果 +export interface CurlParseResult { + method: RequestMethods | string; + url: string; + headers: Record; + body: string; + queryParams: Record; +} diff --git a/frontend/src/views/api-test/components/importCurlDialog.vue b/frontend/src/views/api-test/components/importCurlDialog.vue new file mode 100644 index 0000000000..0c37d5370c --- /dev/null +++ b/frontend/src/views/api-test/components/importCurlDialog.vue @@ -0,0 +1,82 @@ + + + + + diff --git a/frontend/src/views/api-test/debug/index.vue b/frontend/src/views/api-test/debug/index.vue index aee90e3c1f..82e73339f2 100644 --- a/frontend/src/views/api-test/debug/index.vue +++ b/frontend/src/views/api-test/debug/index.vue @@ -9,7 +9,7 @@ @init="(val) => (folderTree = val)" @new-api="addDebugTab" @click-api-node="openApiTab" - @import="importDrawerVisible = true" + @import="importDialogVisible = true" @update-api-node="handleApiUpdateFromModuleTree" @delete-finish="handleDeleteFinish" /> @@ -63,38 +63,7 @@ - - -
- - -
-
+