From 530390f9d4fa37a70d297802c47d2a866ed2a2b6 Mon Sep 17 00:00:00 2001 From: sc Date: Fri, 26 Aug 2022 14:58:10 +0800 Subject: [PATCH] =?UTF-8?q?FIX=20API=E5=90=8C=E6=97=B6=E8=BF=94=E5=9B=9E40?= =?UTF-8?q?1=E6=97=B6=E5=A4=9A=E6=AC=A1=E6=89=A7=E8=A1=8Cconfirm=E5=BC=B9?= =?UTF-8?q?=E7=AA=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/request.js | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/src/utils/request.js b/src/utils/request.js index a5a8dd6c..1edf628c 100644 --- a/src/utils/request.js +++ b/src/utils/request.js @@ -27,6 +27,9 @@ axios.interceptors.request.use( } ); +//FIX 多个API同时401时疯狂弹窗BUG +let MessageBox_401_show = false + // HTTP response 拦截器 axios.interceptors.response.use( (response) => { @@ -45,14 +48,21 @@ axios.interceptors.response.use( message: error.response.data.message || "Status:500,服务器发生错误!" }); } else if (error.response.status == 401) { - ElMessageBox.confirm('当前用户已被登出或无权限访问当前资源,请尝试重新登录后再操作。', '无权限访问', { - type: 'error', - closeOnClickModal: false, - center: true, - confirmButtonText: '重新登录' - }).then(() => { - router.replace({path: '/login'}); - }).catch(() => {}) + if(!MessageBox_401_show){ + MessageBox_401_show = true + ElMessageBox.confirm('当前用户已被登出或无权限访问当前资源,请尝试重新登录后再操作。', '无权限访问', { + type: 'error', + closeOnClickModal: false, + center: true, + confirmButtonText: '重新登录', + beforeClose: (action, instance, done) => { + MessageBox_401_show = false + done() + } + }).then(() => { + router.replace({path: '/login'}); + }).catch(() => {}) + } } else { ElNotification.error({ title: '请求错误',