fix(接口测试): 调试结果返回自动选中mode
This commit is contained in:
parent
556118cd9f
commit
8d1f68666c
|
@ -2,7 +2,7 @@
|
||||||
<div class="text-container">
|
<div class="text-container">
|
||||||
<div @click="active" class="collapse">
|
<div @click="active" class="collapse">
|
||||||
<i class="icon el-icon-arrow-right" :class="{'is-active': isActive}"/>
|
<i class="icon el-icon-arrow-right" :class="{'is-active': isActive}"/>
|
||||||
{{$t('api_report.response')}}
|
{{ $t('api_report.response') }}
|
||||||
</div>
|
</div>
|
||||||
<el-collapse-transition>
|
<el-collapse-transition>
|
||||||
<el-tabs v-model="activeName" v-show="isActive">
|
<el-tabs v-model="activeName" v-show="isActive">
|
||||||
|
@ -10,7 +10,7 @@
|
||||||
<ms-code-edit :mode="mode" :read-only="true" :data="response.body" :modes="modes" ref="codeEdit"/>
|
<ms-code-edit :mode="mode" :read-only="true" :data="response.body" :modes="modes" ref="codeEdit"/>
|
||||||
</el-tab-pane>
|
</el-tab-pane>
|
||||||
<el-tab-pane label="Headers" name="headers" class="pane">
|
<el-tab-pane label="Headers" name="headers" class="pane">
|
||||||
<pre>{{response.headers}}</pre>
|
<pre>{{ response.headers }}</pre>
|
||||||
</el-tab-pane>
|
</el-tab-pane>
|
||||||
<el-tab-pane :label="$t('api_report.assertions')" name="assertions" class="pane assertions">
|
<el-tab-pane :label="$t('api_report.assertions')" name="assertions" class="pane assertions">
|
||||||
<ms-assertion-results :assertions="response.assertions"/>
|
<ms-assertion-results :assertions="response.assertions"/>
|
||||||
|
@ -18,7 +18,7 @@
|
||||||
|
|
||||||
<el-tab-pane v-if="activeName == 'body'" :disabled="true" name="mode" class="pane assertions">
|
<el-tab-pane v-if="activeName == 'body'" :disabled="true" name="mode" class="pane assertions">
|
||||||
<template v-slot:label>
|
<template v-slot:label>
|
||||||
<ms-dropdown :commands="modes" @command="modeChange"/>
|
<ms-dropdown :commands="modes" :default-command="mode" @command="modeChange"/>
|
||||||
</template>
|
</template>
|
||||||
</el-tab-pane>
|
</el-tab-pane>
|
||||||
|
|
||||||
|
@ -28,80 +28,83 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import MsAssertionResults from "./AssertionResults";
|
import MsAssertionResults from "./AssertionResults";
|
||||||
import MsCodeEdit from "../../../common/components/MsCodeEdit";
|
import MsCodeEdit from "../../../common/components/MsCodeEdit";
|
||||||
import MsDropdown from "../../../common/components/MsDropdown";
|
import MsDropdown from "../../../common/components/MsDropdown";
|
||||||
import {BODY_FORMAT} from "../../test/model/ScenarioModel";
|
import {BODY_FORMAT} from "../../test/model/ScenarioModel";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "MsResponseText",
|
name: "MsResponseText",
|
||||||
|
|
||||||
components: {
|
components: {
|
||||||
MsDropdown,
|
MsDropdown,
|
||||||
MsCodeEdit,
|
MsCodeEdit,
|
||||||
MsAssertionResults,
|
MsAssertionResults,
|
||||||
|
},
|
||||||
|
|
||||||
|
props: {
|
||||||
|
response: Object
|
||||||
|
},
|
||||||
|
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
isActive: true,
|
||||||
|
activeName: "body",
|
||||||
|
modes: ['text', 'json', 'xml', 'html'],
|
||||||
|
mode: BODY_FORMAT.TEXT
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
methods: {
|
||||||
|
active() {
|
||||||
|
this.isActive = !this.isActive;
|
||||||
},
|
},
|
||||||
|
modeChange(mode) {
|
||||||
|
this.mode = mode;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
props: {
|
mounted() {
|
||||||
response: Object
|
console.log(this.response.headers);
|
||||||
},
|
if (!this.response.headers) {
|
||||||
|
return;
|
||||||
data() {
|
}
|
||||||
return {
|
if (this.response.headers.indexOf("Content-Type: application/json") > 0) {
|
||||||
isActive: true,
|
this.mode = BODY_FORMAT.JSON;
|
||||||
activeName: "body",
|
|
||||||
modes: ['text', 'json', 'xml', 'html'],
|
|
||||||
mode: BODY_FORMAT.TEXT
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
methods: {
|
|
||||||
active() {
|
|
||||||
this.isActive = !this.isActive;
|
|
||||||
},
|
|
||||||
modeChange(mode) {
|
|
||||||
this.mode = mode;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
created() {
|
|
||||||
console.log(this.response.headers);
|
|
||||||
if (this.response.headers.indexOf("Content-Type: application/json") > 0) {
|
|
||||||
this.mode = BODY_FORMAT.JSON;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
.text-container .icon {
|
.text-container .icon {
|
||||||
padding: 5px;
|
padding: 5px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.text-container .collapse {
|
.text-container .collapse {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
.text-container .collapse:hover {
|
.text-container .collapse:hover {
|
||||||
opacity: 0.8;
|
opacity: 0.8;
|
||||||
}
|
}
|
||||||
|
|
||||||
.text-container .icon.is-active {
|
.text-container .icon.is-active {
|
||||||
transform: rotate(90deg);
|
transform: rotate(90deg);
|
||||||
}
|
}
|
||||||
|
|
||||||
.text-container .pane {
|
.text-container .pane {
|
||||||
background-color: #F5F5F5;
|
background-color: #F5F5F5;
|
||||||
padding: 0 10px;
|
padding: 0 10px;
|
||||||
height: 250px;
|
height: 250px;
|
||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
.text-container .pane.assertions {
|
.text-container .pane.assertions {
|
||||||
padding: 0;
|
padding: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
pre {
|
pre {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
Loading…
Reference in New Issue