修复导出功能:正确处理blob响应
- axios拦截器跳过blob类型响应的code检查 - 从res.data获取blob数据而非res 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -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 || '系统错误';
|
||||
|
||||
@@ -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`
|
||||
|
||||
Reference in New Issue
Block a user