LinHaiBlog

导航

前端解决若依项目登录超时问题

我正在用若依的表单工具制作表单呢,刚画完,准备下载,给我来个登录超时,退到登录界面,心态直接崩溃!!!

  1. 找到下面这个文件

  1. 注释掉下面这段代码
if (code === 401) {
  // if (!isRelogin.show) {
    // isRelogin.show = true;
    // MessageBox.confirm('登录状态已过期,您可以继续留在该页面,或者重新登录', '系统提示', { confirmButtonText: '重新登录', cancelButtonText: '取消', type: 'warning' }).then(() => {
    //   isRelogin.show = false;
    //   store.dispatch('LogOut').then(() => {
    //     location.href = '/index';
    //   })
    // }).catch(() => {
    //   isRelogin.show = false;
    // });
  // }
  // return Promise.reject('无效的会话,或者会话已过期,请重新登录。')
} else if (code === 500) {
  Message({ message: msg, type: 'error' })
  return Promise.reject(new Error(msg))
} else if (code === 601) {
  Message({ message: msg, type: 'warning' })
  return Promise.reject('error')
} else if (code !== 200) {
  Notification.error({ title: msg })
  return Promise.reject('error')
} else {
  return res.data
}

然后就不会有登录超时,重定向到登录页面的问题了

posted on 2024-08-29 10:56  林海世界  阅读(196)  评论(0编辑  收藏  举报