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: '请求错误',