From 26a1999bf53f0a57504f734455b9ae05af45169b Mon Sep 17 00:00:00 2001 From: zhangyu Date: Mon, 14 Mar 2022 13:47:37 +0800 Subject: [PATCH] =?UTF-8?q?fix=EF=BC=9A=E7=99=BB=E5=BD=95=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2=E6=A0=B7=E5=BC=8F=E8=B0=83=E6=95=B4=EF=BC=8C=20?= =?UTF-8?q?=E2=80=98sys/license/token=E2=80=99=20=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E5=AF=BC=E5=87=BA=E7=9A=84=E6=96=87=E4=BB=B6=E5=90=8D=20?= =?UTF-8?q?=E4=BB=8E=E8=BF=94=E5=9B=9E=E5=A4=B4=E9=83=A8=E8=8E=B7=E5=8F=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/assets/css/components/common/login.scss | 2 +- nezha-fronted/src/components/common/login.vue | 12 ++++++++---- .../src/components/page/config/system/license.vue | 10 +++++++--- nezha-fronted/src/http.js | 6 ++++++ 4 files changed, 22 insertions(+), 8 deletions(-) diff --git a/nezha-fronted/src/assets/css/components/common/login.scss b/nezha-fronted/src/assets/css/components/common/login.scss index ba983f320..d915a9f64 100644 --- a/nezha-fronted/src/assets/css/components/common/login.scss +++ b/nezha-fronted/src/assets/css/components/common/login.scss @@ -164,7 +164,7 @@ text-align: center; line-height: 30px; display: flex; - justify-content: space-around; + justify-content: space-between; .license-info { margin-bottom: 10px; color: white; diff --git a/nezha-fronted/src/components/common/login.vue b/nezha-fronted/src/components/common/login.vue index 34e0407d5..7588803e6 100644 --- a/nezha-fronted/src/components/common/login.vue +++ b/nezha-fronted/src/components/common/login.vue @@ -31,7 +31,7 @@
- +
{ - const fileName = 'Login' + '-' + this.getTimeString() + '.xml' + let fileName = this.licenseList.id + '-' + this.getTimeString() + '.xml' + const resFileName = res.headers['content-disposition'].split('=')[1] + if (resFileName) { + fileName = resFileName + } if (window.navigator.msSaveOrOpenBlob) { // 兼容ie11 - const blobObject = new Blob([res]) + const blobObject = new Blob([res.data]) window.navigator.msSaveOrOpenBlob(blobObject, fileName) } else { - const url = URL.createObjectURL(new Blob([res])) + const url = URL.createObjectURL(new Blob([res.data])) const a = document.createElement('a') document.body.appendChild(a) // 此处增加了将创建的添加到body当中 a.href = url diff --git a/nezha-fronted/src/components/page/config/system/license.vue b/nezha-fronted/src/components/page/config/system/license.vue index 44a9b1d76..2b80d6aa0 100644 --- a/nezha-fronted/src/components/page/config/system/license.vue +++ b/nezha-fronted/src/components/page/config/system/license.vue @@ -194,13 +194,17 @@ export default { }, downloadLicense () { this.$get('/sys/license/token').then(res => { - const fileName = this.licenseList.id + '-' + this.getTimeString() + '.xml' + let fileName = this.licenseList.id + '-' + this.getTimeString() + '.xml' + const resFileName = res.headers['content-disposition'].split('=')[1] + if (resFileName) { + fileName = resFileName + } if (window.navigator.msSaveOrOpenBlob) { // 兼容ie11 - const blobObject = new Blob([res]) + const blobObject = new Blob([res.data]) window.navigator.msSaveOrOpenBlob(blobObject, fileName) } else { - const url = URL.createObjectURL(new Blob([res])) + const url = URL.createObjectURL(new Blob([res.data])) const a = document.createElement('a') document.body.appendChild(a) // 此处增加了将创建的添加到body当中 a.href = url diff --git a/nezha-fronted/src/http.js b/nezha-fronted/src/http.js index 55321bb5e..c2df199c5 100644 --- a/nezha-fronted/src/http.js +++ b/nezha-fronted/src/http.js @@ -77,6 +77,12 @@ export function get (url, params) { axios.get(url, { params: params }).then(response => { + if (url.indexOf('/sys/license/token') !== -1) { + resolve({ + data: response.data, + headers: response.headers + }) + } resolve(response.data) }).catch(err => { if (err.response) {