From 843d7ed3b1650ab285905db3c8ef08fb9b4b480b Mon Sep 17 00:00:00 2001 From: "Captain.B" Date: Fri, 8 May 2020 18:02:58 +0800 Subject: [PATCH] =?UTF-8?q?=E6=97=A5=E5=BF=97=E4=B8=8B=E8=BD=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../report/components/LogDetails.vue | 19 ++++++++++++++++++- frontend/src/i18n/en-US.js | 1 + frontend/src/i18n/zh-CN.js | 2 +- 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/frontend/src/business/components/performance/report/components/LogDetails.vue b/frontend/src/business/components/performance/report/components/LogDetails.vue index a6a6a59f54..405d8bc567 100644 --- a/frontend/src/business/components/performance/report/components/LogDetails.vue +++ b/frontend/src/business/components/performance/report/components/LogDetails.vue @@ -2,7 +2,8 @@
- {{item}} + {{item.substring(0, 2048) }}... + {{$t('load_test.download_log_file')}}
@@ -23,6 +24,22 @@ this.result = this.$get("/performance/report/log/" + this.id, res => { this.logContent = res.data; }) + }, + downloadLogFile(content) { + const filename = 'jmeter.log' + const blob = new Blob([content]); + if ("download" in document.createElement("a")) { + // 非IE下载 + // chrome/firefox + let aTag = document.createElement('a'); + aTag.download = filename; + aTag.href = URL.createObjectURL(blob); + aTag.click(); + URL.revokeObjectURL(aTag.href) + } else { + // IE10+下载 + navigator.msSaveBlob(blob, filename); + } } }, watch: { diff --git a/frontend/src/i18n/en-US.js b/frontend/src/i18n/en-US.js index 2232c263ca..3c42ed336f 100644 --- a/frontend/src/i18n/en-US.js +++ b/frontend/src/i18n/en-US.js @@ -181,6 +181,7 @@ export default { 'create': 'Create Test', 'select_resource_pool': 'Please Select Resource Pool', 'resource_pool_is_null': 'Resource Pool is empty', + 'download_log_file': 'Download', }, api_test: { 'select_resource_pool': 'Please select resource pool' diff --git a/frontend/src/i18n/zh-CN.js b/frontend/src/i18n/zh-CN.js index b52c9cc388..fc02caec1b 100644 --- a/frontend/src/i18n/zh-CN.js +++ b/frontend/src/i18n/zh-CN.js @@ -183,7 +183,7 @@ export default { 'create': '创建测试', 'select_resource_pool': '请选择资源池', 'resource_pool_is_null': '资源池为空', - + 'download_log_file': '下载完整日志文件', }, api_test: { save_and_run: "保存并执行",