From 0444cee0b524893a5ef2c18536f31edf38f16013 Mon Sep 17 00:00:00 2001 From: wangxiaoshuang <825034831@qq.com> Date: Tue, 23 Dec 2025 10:07:55 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8B=E8=BD=BD=E6=96=87=E4=BB=B6=E4=BC=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/request-download.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/utils/request-download.js b/src/utils/request-download.js index 1d2f349..9727e24 100644 --- a/src/utils/request-download.js +++ b/src/utils/request-download.js @@ -29,6 +29,21 @@ service.interceptors.request.use( service.interceptors.response.use( response => { const res = response.data + let contentDisposition = response.headers['content-disposition'] + if (contentDisposition) { + if (contentDisposition.includes('zip')) { + let fileName = contentDisposition.split('; ')[1].split('=')[1] + fileName = decodeURI(fileName) + const a = document.createElement('a') + const href = URL.createObjectURL(new Blob([res], { type: response.headers['content-type'] })) + a.download = fileName + a.href = href + a.click() + URL.revokeObjectURL(href) + return true + } + } + let fileReader = new FileReader(); fileReader.onload = function () { try {