From 9e1ae938f83b9e6a83ad025bbbc25e4e3e255418 Mon Sep 17 00:00:00 2001 From: hyt <958868763@qq.com> Date: Mon, 27 May 2024 11:24:30 +0800 Subject: [PATCH] =?UTF-8?q?5.26=E4=BF=AE=E6=94=B9=E6=89=80=E6=9C=89?= =?UTF-8?q?=E5=B7=B2=E5=87=BA=E7=8E=B0=E7=9A=84bug=E5=92=8C=E4=BC=98?= =?UTF-8?q?=E5=8C=96=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/request.js | 65 ++++++++++--------- src/views/applicationList/index.vue | 2 +- .../masterDataOptions/dataOrigin/index.vue | 3 +- src/views/masterDataOptions/index.vue | 2 +- 4 files changed, 40 insertions(+), 32 deletions(-) diff --git a/src/utils/request.js b/src/utils/request.js index 3fdbcf5..867a63b 100644 --- a/src/utils/request.js +++ b/src/utils/request.js @@ -37,6 +37,8 @@ let timer = null let isRefreshing = false //重试队列 let requests = [] +// 在模块作用域定义一个全局标志变量 +let isHandlingTokenInvalid = false axios.defaults.headers['Content-Type'] = 'application/json;charset=utf-8' // 创建axios实例 @@ -111,7 +113,6 @@ service.interceptors.request.use( // 响应拦截器 service.interceptors.response.use( (res) => { - console.log(res, '相应拦截器拦截内容') // 请求完成时清除唯一标识符 const requestIdentifier = `${res.config.url}-${res.config.method}` const index = requests.indexOf(requestIdentifier) @@ -133,37 +134,43 @@ service.interceptors.response.use( } if (code === '500') { - MessageBox.confirm(msg, '系统提示', { - confirmButtonText: '确定', - showCancelButton: false, - showClose: false, - closeOnClickModal: false, - closeOnPressEscape: false, - type: 'error' - }) - .then(() => { - console.log(res, '相应拦截器拦截内容') - if (msg === 'token无效') { + // 判断是否在处理 token 无效情况 + if (msg === 'token无效' && isHandlingTokenInvalid) return + if (msg === 'token无效' && !isHandlingTokenInvalid) { + isHandlingTokenInvalid = true; + MessageBox.confirm('token过期请重新登录!', '系统提示', { + confirmButtonText: '确定', + showCancelButton: false, + showClose: false, + closeOnClickModal: false, + closeOnPressEscape: false, + type: 'error' + }) + .then(() => { store.dispatch('LogOut').then(() => { route.replace({ path: '/login' - }) - - }) - } - if (res.config.headers.dj==='queryTreeById') { - store.dispatch('LogOut').then(() => { - route.replace({ - path: '/login' - }) - - }) - } - - }) - .catch(() => { - }) - return Promise.reject(new Error(msg)) + }); + // 重置标志变量 + isHandlingTokenInvalid = false; + }); + }) + .catch(() => { + // 处理取消逻辑 + isHandlingTokenInvalid = false; + }); + } else { + // 其他错误处理 + MessageBox.confirm(msg, '系统提示', { + confirmButtonText: '确定', + showCancelButton: false, + showClose: false, + closeOnClickModal: false, + closeOnPressEscape: false, + type: 'error' + }); + } + return Promise.reject(new Error(msg)); } else if (code == '1002') { MessageBox.confirm(msg, '系统提示', { diff --git a/src/views/applicationList/index.vue b/src/views/applicationList/index.vue index bca65ee..42e7fb8 100644 --- a/src/views/applicationList/index.vue +++ b/src/views/applicationList/index.vue @@ -16,7 +16,7 @@
- +
diff --git a/src/views/masterDataOptions/dataOrigin/index.vue b/src/views/masterDataOptions/dataOrigin/index.vue index 2fee542..c5af7aa 100644 --- a/src/views/masterDataOptions/dataOrigin/index.vue +++ b/src/views/masterDataOptions/dataOrigin/index.vue @@ -882,8 +882,9 @@ export default { return mainItem.sublistMdmModuleDbFileds.some((item, index02) => { if (!item.chName) { this.$vmNews(`数据表第${index + 1}行表中的${index02 + 1}行表字段数据填写不全`, 'warning') + return true + } - return true }) }) if (flag) return diff --git a/src/views/masterDataOptions/index.vue b/src/views/masterDataOptions/index.vue index cf786cb..592d032 100644 --- a/src/views/masterDataOptions/index.vue +++ b/src/views/masterDataOptions/index.vue @@ -5,7 +5,7 @@