fix(性能测试): 修复性能测试不显示文本内容的缺陷

--bug=1034382 --user=宋天阳 【性能测试】报告-错误记录-所有请求-查看详情-接口返回text、json、html、xml-显示加载失败 https://www.tapd.cn/55049933/s/1452391
This commit is contained in:
song-tianyang 2024-01-17 16:11:33 +08:00 committed by 建国
parent ce8ad81e4e
commit 373b05a448
2 changed files with 24 additions and 9 deletions

View File

@ -10,7 +10,7 @@
</template> </template>
<script> <script>
import { formatJson, formatXml } from 'metersphere-frontend/src/utils/format-utils'; import {formatJson, formatXml} from 'metersphere-frontend/src/utils/format-utils';
import toDiffableHtml from 'diffable-html'; import toDiffableHtml from 'diffable-html';
import editor from 'vue2-ace-editor'; import editor from 'vue2-ace-editor';
import 'brace/ext/language_tools'; //language extension prerequisite... import 'brace/ext/language_tools'; //language extension prerequisite...

View File

@ -171,7 +171,8 @@ export default {
}, },
showPicture() { showPicture() {
if (this.responseResult.contentType && this.contentType.includes(this.responseResult.contentType)) { if (this.responseResult.contentType && this.contentType.includes(this.responseResult.contentType)) {
this.modes.push('picture') this.modes.push('picture');
this.mode = 'picture';
this.srcUrl = 'data:' + this.responseResult.contentType + ';base64,' + this.responseResult.imageUrl; this.srcUrl = 'data:' + this.responseResult.contentType + ';base64,' + this.responseResult.imageUrl;
} }
}, },
@ -193,6 +194,19 @@ export default {
} }
}); });
} }
if (this.response && this.response.responseResult && this.response.responseResult.contentType) {
let contentType = this.response.responseResult.contentType;
if (contentType.includes('application/json')) {
this.mode = this.bodyFormat.JSON;
} else if (contentType.includes('text/html')) {
this.mode = this.bodyFormat.HTML;
} else if (contentType.includes('text/xml')) {
this.mode = this.bodyFormat.XML;
} else {
this.mode = this.bodyFormat.TEXT;
}
}
this.msCodeReload();
}, },
msCodeReload() { msCodeReload() {
this.isMsCodeEditShow = false; this.isMsCodeEditShow = false;
@ -200,13 +214,7 @@ export default {
this.isMsCodeEditShow = true; this.isMsCodeEditShow = true;
}); });
}, },
isPicture() {
return (
this.responseResult.contentType &&
this.contentType.includes(this.responseResult.contentType) &&
this.mode === 'picture'
);
},
setReqMessage() { setReqMessage() {
if (this.response) { if (this.response) {
if (!this.response.url) { if (!this.response.url) {
@ -273,6 +281,13 @@ export default {
? this.response.responseResult ? this.response.responseResult
: {}; : {};
}, },
isPicture() {
return (
this.responseResult.contentType &&
this.contentType.includes(this.responseResult.contentType) &&
this.mode === 'picture'
);
},
}, },
}; };
</script> </script>