接口测试支持更多请求方式

This commit is contained in:
zhangdaiscott
2020-12-09 17:36:00 +08:00
parent 54751428b2
commit 5863f00b26
@@ -1,10 +1,12 @@
<template> <template>
<a-card :bordered="false"> <a-card :bordered="false">
<a-row> <a-row style="margin-top: 20px">
<a-col :md="2" :sm="4"> <a-col :md="2" :sm="4">
<a-select defaultValue="POST" style="width: 90px" @change="handleChange" size="large"> <a-select defaultValue="POST" style="width: 90px" @change="handleChange" size="large">
<a-select-option value="POST">POST</a-select-option> <a-select-option value="POST">POST</a-select-option>
<!--<a-select-option value="GET">GET</a-select-option>--> <a-select-option value="GET">GET</a-select-option>
<a-select-option value="PUT">PUT</a-select-option>
<a-select-option value="DELETE">DELETE</a-select-option>
</a-select> </a-select>
</a-col> </a-col>
<a-col :md="22" :sm="20"> <a-col :md="22" :sm="20">
@@ -19,7 +21,7 @@
<a-tabs defaultActiveKey="2"> <a-tabs defaultActiveKey="2">
<a-tab-pane tab="params" key="2"> <a-tab-pane tab="params" key="2">
<textarea style="width:100%;font-size: 16px;font-weight:500" :rows="13" @input="changeVal"> <textarea style="width:100%;font-size: 16px;font-weight:500" :rows="13" @blur="changeVal">
</textarea> </textarea>
</a-tab-pane> </a-tab-pane>
</a-tabs> </a-tabs>
@@ -33,7 +35,7 @@
</a-card> </a-card>
</template> </template>
<script> <script>
import { postAction,getAction } from '@/api/manage' import { axios } from '@/utils/request'
import { ACCESS_TOKEN } from "@/store/mutation-types" import { ACCESS_TOKEN } from "@/store/mutation-types"
import Vue from 'vue' import Vue from 'vue'
export default { export default {
@@ -49,28 +51,25 @@
methods: { methods: {
onSearch (value) { onSearch (value) {
let that = this let that = this
if(!value){
that.$message.error("请填写路径")
return false
}
this.resultJson = {}; this.resultJson = {};
if("POST"===this.requestMethod.toUpperCase()){ axios({
postAction(value,this.paramJson).then((res)=>{ url: value,
method: this.requestMethod,
data: this.paramJson
}).then((res) => {
console.log(res) console.log(res)
this.resultJson = res this.resultJson = res
}).catch((err) => { }).catch((err) => {
that.$message.error("请求异常:"+err) that.$message.error("请求异常:"+err)
}) })
}else {
getAction(value,this.paramJson).then((res)=>{
console.log(res)
this.resultJson = res;
}).catch((err) => {
that.$message.error("请求异常:"+err)
})
}
}, },
changeVal(e){ changeVal(e){
try { try {
let json = e.target.value; let json = e.target.value;
json = json.replace(/\n/g,"");
json = json.replace(/\s*/g,"");
if(json.indexOf(",}")>0){ if(json.indexOf(",}")>0){
json = json.replace(",}","}"); json = json.replace(",}","}");
} }