From 98ed31b00c594aa10ff31278577a3e22ab4922d6 Mon Sep 17 00:00:00 2001 From: liruiqiang <3151805288@qq.com> Date: Mon, 8 Dec 2025 15:00:08 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E7=8A=B6=E6=80=81=E7=A0=81?= =?UTF-8?q?=E8=B7=B3=E8=BD=AC=E5=88=B0=E7=99=BB=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/myAxios.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/utils/myAxios.js b/src/utils/myAxios.js index c4b5434..0b020e7 100644 --- a/src/utils/myAxios.js +++ b/src/utils/myAxios.js @@ -41,6 +41,9 @@ myAxios.interceptors.response.use( // 假设后端接口规范:成功时 code=200,其他为错误 if (res.code !== 200) { + if( res.code == 401){ + router.push('/login') + } // 错误提示(根据后端消息提示,或自定义) ElMessage.error(res.message || '操作失败') return Promise.reject(new Error(res.message || 'Error')) @@ -57,7 +60,7 @@ myAxios.interceptors.response.use( switch (error.response.status) { case 401: message = '未授权,请重新登录' - router.push('/login') + // router.push('/login') break case 403: message = '没有权限访问'