From 7f8c5c630b53cf29ab823fb7526650e1e9b2e93c Mon Sep 17 00:00:00 2001 From: DevOps Date: Wed, 24 Dec 2025 13:58:21 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=AF=BC=E5=87=BA=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=EF=BC=9A=E6=AD=A3=E7=A1=AE=E5=A4=84=E7=90=86blob?= =?UTF-8?q?=E5=93=8D=E5=BA=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - axios拦截器跳过blob类型响应的code检查 - 从res.data获取blob数据而非res 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- src/axios.js | 4 ++++ src/views/martial/schedule/index.vue | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/axios.js b/src/axios.js index 7d9b5e5..e24edb9 100644 --- a/src/axios.js +++ b/src/axios.js @@ -98,6 +98,10 @@ axios.interceptors.request.use( axios.interceptors.response.use( res => { NProgress.done(); + // 如果是 blob 类型响应(文件下载),直接返回 + if (res.config.responseType === 'blob') { + return res; + } const status = res.data.code || res.status; const statusWhiteList = website.statusWhiteList || []; const message = res.data.msg || res.data.error_description || '系统错误'; diff --git a/src/views/martial/schedule/index.vue b/src/views/martial/schedule/index.vue index 1498dd7..814bbd9 100644 --- a/src/views/martial/schedule/index.vue +++ b/src/views/martial/schedule/index.vue @@ -1117,7 +1117,8 @@ export default { try { this.loading = true const res = await exportSchedule(this.competitionId) - const blob = new Blob([res], { type: 'application/vnd.ms-excel' }) + // axios 返回的是 response 对象,需要取 res.data + const blob = new Blob([res.data], { type: 'application/vnd.ms-excel' }) const link = document.createElement('a') link.href = window.URL.createObjectURL(blob) link.download = `赛程表_${this.competitionInfo.competitionName || this.competitionId}.xlsx`