From 3c6d3aca5d984622d73d64248a99bc73ca6e9441 Mon Sep 17 00:00:00 2001 From: wxg0103 <727495428@qq.com> Date: Mon, 5 Dec 2022 17:58:32 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=8E=A5=E5=8F=A3=E6=B5=8B=E8=AF=95):=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=9C=BA=E6=99=AF=E6=8A=A5=E5=91=8A=E5=90=8D?= =?UTF-8?q?=E7=A7=B0=E5=B8=A6=E7=89=B9=E6=AE=8A=E5=AD=97=E7=AC=A6=E5=AF=BC?= =?UTF-8?q?=E5=87=BA=E5=A4=B1=E8=B4=A5=E7=9A=84=E7=BC=BA=E9=99=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1020579 --user=王孝刚 [接口测试] github#20205导出场景报告,格式为file,非pdf,手动改为.pdf后缀,可查看 https://www.tapd.cn/55049933/s/1313107 --- .../automation/report/ApiReportDetail.vue | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/api-test/frontend/src/business/automation/report/ApiReportDetail.vue b/api-test/frontend/src/business/automation/report/ApiReportDetail.vue index f5b7655ff6..f81ec557d6 100644 --- a/api-test/frontend/src/business/automation/report/ApiReportDetail.vue +++ b/api-test/frontend/src/business/automation/report/ApiReportDetail.vue @@ -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'));