From 029ab94f0675447c050a1324838f8965e657b216 Mon Sep 17 00:00:00 2001 From: wangqiujuan0808 <578331299@qq.com> Date: Tue, 25 Jun 2024 19:31:22 +0800 Subject: [PATCH] Update axios.js --- src/utils/axios.js | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/utils/axios.js b/src/utils/axios.js index a869df9..7ac0991 100644 --- a/src/utils/axios.js +++ b/src/utils/axios.js @@ -35,21 +35,20 @@ axios.interceptors.response.use( } } } - if(res.config.headers['action'] == 53211) { // 导出文件 + if(!res.request || res.request.responseType === 'blob') { // 特殊情况处理,导出文件 return res; } - const ret = res.data; // token过期 - if (ret.code === 3004) { + if (res.data.code === 3004) { localRemove("token"); ElMessage.closeAll(); - ElMessage.error(ret.message || "Token异常,请重新登录"); + ElMessage.error(res.data.message || "Token异常,请重新登录"); router.push({ path: "/login" }); - return Promise.reject(ret); + return Promise.reject(res.data); } - return ret; + return Promise.resolve(res.data); }, (error) => { ElMessage.closeAll();