refactor(接口定义): 重构HTTP请求,规范代码

This commit is contained in:
fit2-zhao 2021-01-18 13:25:44 +08:00
parent b0d01bebba
commit c1303bd8a8
15 changed files with 23 additions and 74 deletions

View File

@ -67,7 +67,7 @@
import MsSqlBasisParameters from "../../../definition/components/request/database/BasisParameters";
import MsTcpBasisParameters from "../../../definition/components/request/tcp/TcpBasisParameters";
import MsDubboBasisParameters from "../../../definition/components/request/dubbo/BasisParameters";
import MsApiRequestForm from "../../../definition/components/request/http/ApiRequestForm";
import MsApiRequestForm from "../../../definition/components/request/http/ApiHttpRequestForm";
import {REQ_METHOD} from "../../../definition/model/JsonData";
import MsRequestResultTail from "../../../definition/components/response/RequestResultTail";
import MsRun from "../../../definition/components/Run";

View File

@ -31,7 +31,7 @@
import MsSqlBasisParameters from "../../../definition/components/request/database/BasisParameters";
import MsTcpBasisParameters from "../../../definition/components/request/tcp/TcpBasisParameters";
import MsDubboBasisParameters from "../../../definition/components/request/dubbo/BasisParameters";
import MsApiRequestForm from "../../../definition/components/request/http/ApiRequestForm";
import MsApiRequestForm from "../../../definition/components/request/http/ApiHttpRequestForm";
import ApiBaseComponent from "../common/ApiBaseComponent";
export default {

View File

@ -25,17 +25,13 @@
{{ $t('api_test.definition.request.body_binary') }}
</el-radio>
</el-radio-group>
<el-row v-if="body.type == 'Form Data' || body.type == 'WWW_FORM'">
<el-link class="ms-el-link" @click="batchAdd"> {{$t("commons.batch_add")}}</el-link>
</el-row>
<div style="min-width: 1200px;" v-if="body.type == 'Form Data' || body.type == 'WWW_FORM'">
<el-row v-if="body.type == 'Form Data' || body.type == 'WWW_FORM'">
<el-link class="ms-el-link" @click="batchAdd"> {{$t("commons.batch_add")}}</el-link>
</el-row>
<ms-api-variable :is-read-only="isReadOnly"
:parameters="body.kvs"
:isShowEnable="isShowEnable" type="body" v-if="body.type == 'Form Data'"/>
<ms-api-from-url-variable :is-read-only="isReadOnly"
:parameters="body.kvs"
type="body" v-if="body.type == 'WWW_FORM'"/>
:isShowEnable="isShowEnable" type="body"/>
</div>
<div v-if="body.type == 'JSON'">
<div style="padding: 10px">

View File

@ -92,11 +92,11 @@
</template>
<script>
import {_getBodyUploadFiles, getCurrentProjectID, getUUID} from "../../../../../../common/js/utils";
import {_getBodyUploadFiles, getCurrentProjectID} from "../../../../../../common/js/utils";
import {PRIORITY, RESULT_MAP} from "../../model/JsonData";
import MsTag from "../../../../common/components/MsTag";
import MsTipButton from "../../../../common/components/MsTipButton";
import MsApiRequestForm from "../request/http/ApiRequestForm";
import MsApiRequestForm from "../request/http/ApiHttpRequestForm";
import ApiEnvironmentConfig from "../environment/ApiEnvironmentConfig";
import MsApiAssertions from "../assertion/ApiAssertions";
import MsSqlBasisParameters from "../request/database/BasisParameters";

View File

@ -108,7 +108,8 @@
</template>
<script>
import MsApiRequestForm from "../request/http/ApiRequestForm";
import MsApiRequestForm from "../request/http/ApiHttpRequestForm";
import MsResponseText from "../response/ResponseText";
import {WORKSPACE_ID} from '../../../../../../common/js/constants';
import {API_STATUS, REQ_METHOD} from "../../model/JsonData";

View File

@ -29,7 +29,6 @@
</template>
<script>
import MsApiRequestForm from "../request/http/ApiRequestForm";
import MsResponseResult from "../response/ResponseResult";
import MsRequestMetric from "../response/RequestMetric";
import {getUUID, getCurrentUser} from "@/common/js/utils";
@ -42,7 +41,7 @@
export default {
name: "ApiConfig",
components: {MsRequestResultTail, MsResponseResult, MsApiRequestForm, MsRequestMetric, MsResponseText, MsRun, MsBasisParameters},
components: {MsRequestResultTail, MsResponseResult, MsRequestMetric, MsResponseText, MsRun, MsBasisParameters},
props: {
currentProtocol: String,
scenario: Boolean,

View File

@ -44,7 +44,7 @@
</template>
<script>
import MsApiRequestForm from "../request/http/ApiRequestForm";
import MsApiRequestForm from "../request/http/ApiHttpRequestForm";
import MsResponseResult from "../response/ResponseResult";
import MsRequestMetric from "../response/RequestMetric";
import {getUUID, getCurrentUser} from "@/common/js/utils";

View File

@ -31,7 +31,6 @@
</template>
<script>
import MsApiRequestForm from "../request/http/ApiRequestForm";
import MsResponseResult from "../response/ResponseResult";
import MsRequestMetric from "../response/RequestMetric";
import {getUUID, getCurrentUser} from "@/common/js/utils";
@ -44,7 +43,7 @@
export default {
name: "ApiConfig",
components: {MsRequestResultTail, MsResponseResult, MsApiRequestForm, MsRequestMetric, MsResponseText, MsRun, MsBasisParameters},
components: {MsRequestResultTail, MsResponseResult, MsRequestMetric, MsResponseText, MsRun, MsBasisParameters},
props: {
currentProtocol: String,
scenario: Boolean,

View File

@ -40,7 +40,7 @@
</template>
<script>
import MsApiRequestForm from "../request/http/ApiRequestForm";
import MsApiRequestForm from "../request/http/ApiHttpRequestForm";
import MsResponseResult from "../response/ResponseResult";
import MsRequestMetric from "../response/RequestMetric";
import {getUUID, getCurrentUser} from "@/common/js/utils";

View File

@ -14,6 +14,10 @@
</div>
</span>
</el-tooltip>
<el-row>
<el-link class="ms-el-link" @click="batchAdd"> {{$t("commons.batch_add")}}</el-link>
</el-row>
<ms-api-key-value :is-read-only="isReadOnly" :isShowEnable="isShowEnable" :suggestions="headerSuggestions" :items="headers"/>
</el-tab-pane>
@ -265,6 +269,9 @@
case "rest":
this.request.rest.unshift(item);
break;
case "headers":
this.request.headers.unshift(item);
break;
default:
break;
}

View File

@ -1,49 +0,0 @@
<template>
<div class="request-form">
<component :is="component" :showScript="showScript" :is-read-only="isReadOnly" :referenced="referenced" :request="request" :response="response" :headers="headers" :isShowEnable="isShowEnable"/>
</div>
</template>
<script>
import MsApiHttpRequestForm from "./ApiHttpRequestForm";
export default {
name: "MsApiRequestForm",
components: {MsApiHttpRequestForm},
props: {
request: {},
response: {},
headers: Array,
isShowEnable: {
type: Boolean,
default: true
},
showScript: {
type: Boolean,
default: true,
},
referenced: {
type: Boolean,
default: false
},
isReadOnly: {
type: Boolean,
default: false
}
},
computed: {
component({request: {type}}) {
return "MsApiHttpRequestForm";
}
}
}
</script>
<style scoped>
.request-form >>> .debug-button {
margin-left: auto;
display: block;
margin-right: 10px;
}
</style>

View File

@ -43,7 +43,6 @@
</template>
<script>
import MsApiRequestForm from "../request/http/ApiRequestForm";
import {downloadFile, getUUID, getCurrentProjectID} from "@/common/js/utils";
import MsApiCaseList from "../case/ApiCaseList";
import MsContainer from "../../../../common/components/MsContainer";
@ -58,7 +57,6 @@
export default {
name: "RunTestDubboPage",
components: {
MsApiRequestForm,
MsApiCaseList,
MsContainer,
MsBottomContainer,

View File

@ -69,7 +69,7 @@
</template>
<script>
import MsApiRequestForm from "../request/http/ApiRequestForm";
import MsApiRequestForm from "../request/http/ApiHttpRequestForm";
import {downloadFile, getUUID, getCurrentProjectID} from "@/common/js/utils";
import MsApiCaseList from "../case/ApiCaseList";
import MsContainer from "../../../../common/components/MsContainer";

View File

@ -42,7 +42,6 @@
</template>
<script>
import MsApiRequestForm from "../request/http/ApiRequestForm";
import {downloadFile, getUUID, getCurrentProjectID} from "@/common/js/utils";
import MsApiCaseList from "../case/ApiCaseList";
import MsContainer from "../../../../common/components/MsContainer";
@ -57,7 +56,6 @@
export default {
name: "RunTestSQLPage",
components: {
MsApiRequestForm,
MsApiCaseList,
MsContainer,
MsBottomContainer,

View File

@ -45,7 +45,7 @@
</template>
<script>
import MsApiRequestForm from "../request/http/ApiRequestForm";
import MsApiRequestForm from "../request/http/ApiHttpRequestForm";
import {downloadFile, getUUID, getCurrentProjectID} from "@/common/js/utils";
import MsApiCaseList from "../case/ApiCaseList";
import MsContainer from "../../../../common/components/MsContainer";