5.26修改所有已出现的bug和优化。

This commit is contained in:
hyt 2024-05-27 11:24:30 +08:00
parent 6fd6341960
commit 9e1ae938f8
4 changed files with 40 additions and 32 deletions

View File

@ -37,6 +37,8 @@ let timer = null
let isRefreshing = false let isRefreshing = false
//重试队列 //重试队列
let requests = [] let requests = []
// 在模块作用域定义一个全局标志变量
let isHandlingTokenInvalid = false
axios.defaults.headers['Content-Type'] = 'application/json;charset=utf-8' axios.defaults.headers['Content-Type'] = 'application/json;charset=utf-8'
// 创建axios实例 // 创建axios实例
@ -111,7 +113,6 @@ service.interceptors.request.use(
// 响应拦截器 // 响应拦截器
service.interceptors.response.use( service.interceptors.response.use(
(res) => { (res) => {
console.log(res, '相应拦截器拦截内容')
// 请求完成时清除唯一标识符 // 请求完成时清除唯一标识符
const requestIdentifier = `${res.config.url}-${res.config.method}` const requestIdentifier = `${res.config.url}-${res.config.method}`
const index = requests.indexOf(requestIdentifier) const index = requests.indexOf(requestIdentifier)
@ -133,37 +134,43 @@ service.interceptors.response.use(
} }
if (code === '500') { if (code === '500') {
MessageBox.confirm(msg, '系统提示', { // 判断是否在处理 token 无效情况
confirmButtonText: '确定', if (msg === 'token无效' && isHandlingTokenInvalid) return
showCancelButton: false, if (msg === 'token无效' && !isHandlingTokenInvalid) {
showClose: false, isHandlingTokenInvalid = true;
closeOnClickModal: false, MessageBox.confirm('token过期请重新登录', '系统提示', {
closeOnPressEscape: false, confirmButtonText: '确定',
type: 'error' showCancelButton: false,
}) showClose: false,
.then(() => { closeOnClickModal: false,
console.log(res, '相应拦截器拦截内容') closeOnPressEscape: false,
if (msg === 'token无效') { type: 'error'
})
.then(() => {
store.dispatch('LogOut').then(() => { store.dispatch('LogOut').then(() => {
route.replace({ route.replace({
path: '/login' path: '/login'
}) });
// 重置标志变量
}) isHandlingTokenInvalid = false;
} });
if (res.config.headers.dj==='queryTreeById') { })
store.dispatch('LogOut').then(() => { .catch(() => {
route.replace({ // 处理取消逻辑
path: '/login' isHandlingTokenInvalid = false;
}) });
} else {
}) // 其他错误处理
} MessageBox.confirm(msg, '系统提示', {
confirmButtonText: '确定',
}) showCancelButton: false,
.catch(() => { showClose: false,
}) closeOnClickModal: false,
return Promise.reject(new Error(msg)) closeOnPressEscape: false,
type: 'error'
});
}
return Promise.reject(new Error(msg));
} else if (code == '1002') { } else if (code == '1002') {
MessageBox.confirm(msg, '系统提示', { MessageBox.confirm(msg, '系统提示', {

View File

@ -16,7 +16,7 @@
</el-select> </el-select>
</div> </div>
<div class="chunk"> <div class="chunk">
<el-input placeholder="应用名称、厂商" v-model="searchForm.nameOrManufacturer" @keyup.enter.native="submitsearchForm"> <el-input placeholder="应用名称、厂商" v-model="searchForm.nameOrManufacturer" @change="submitsearchForm">
<i slot="suffix" class="el-input__icon el-icon-search" @click="submitsearchForm"></i> <i slot="suffix" class="el-input__icon el-icon-search" @click="submitsearchForm"></i>
</el-input> </el-input>
</div> </div>

View File

@ -882,8 +882,9 @@ export default {
return mainItem.sublistMdmModuleDbFileds.some((item, index02) => { return mainItem.sublistMdmModuleDbFileds.some((item, index02) => {
if (!item.chName) { if (!item.chName) {
this.$vmNews(`数据表第${index + 1}行表中的${index02 + 1}行表字段数据填写不全`, 'warning') this.$vmNews(`数据表第${index + 1}行表中的${index02 + 1}行表字段数据填写不全`, 'warning')
return true
} }
return true
}) })
}) })
if (flag) return if (flag) return

View File

@ -5,7 +5,7 @@
<div class="search"> <div class="search">
<div class="chunk"> <div class="chunk">
<el-input placeholder="主数据名称" v-model="searchForm.mdmName" <el-input placeholder="主数据名称" v-model="searchForm.mdmName"
@keyup.enter.native="submitsearchForm"> @change="submitsearchForm">
<i slot="suffix" class="el-input__icon el-icon-search" @click="submitsearchForm"></i> <i slot="suffix" class="el-input__icon el-icon-search" @click="submitsearchForm"></i>
</el-input> </el-input>
</div> </div>