fix(接口测试): 修复场景报告名称带特殊字符导出失败的缺陷

--bug=1020579 --user=王孝刚 [接口测试]
github#20205导出场景报告,格式为file,非pdf,手动改为.pdf后缀,可查看
https://www.tapd.cn/55049933/s/1313107
This commit is contained in:
wxg0103 2022-12-05 17:58:32 +08:00 committed by wxg0103
parent dcc5e013e5
commit 3c6d3aca5d
1 changed files with 33 additions and 0 deletions

View File

@ -695,6 +695,7 @@ export default {
this.reportExportVisible = true;
let reset = this.exportReportReset;
let name = this.report.name;
name = this.encodeSearchKey(name);
this.$nextTick(() => {
setTimeout(() => {
downloadPDF(document.getElementById('apiTestReport'), name || 'scenario-report');
@ -702,6 +703,38 @@ export default {
}, 5000);
});
},
//
encodeSearchKey(key) {
const encodeArr = [
{
code: '%',
encode: '%25',
},
{
code: '?',
encode: '%3F',
},
{
code: '#',
encode: '%23',
},
{
code: '&',
encode: '%26',
},
{
code: '=',
encode: '%3D',
},
];
return key.replace(/[%?#&=]/g, ($, index, str) => {
for (const k of encodeArr) {
if (k.code === $) {
return k.encode;
}
}
});
},
handleSave() {
if (!this.report.name) {
this.$warning(this.$t('api_test.automation.report_name_info'));