作者 RuoYi

修复登录失效后多次请求提示多次弹窗问题

@@ -7,6 +7,8 @@ import { tansParams, blobValidate } from "@/utils/ruoyi"; @@ -7,6 +7,8 @@ import { tansParams, blobValidate } from "@/utils/ruoyi";
7 import { saveAs } from 'file-saver' 7 import { saveAs } from 'file-saver'
8 8
9 let downloadLoadingInstance; 9 let downloadLoadingInstance;
  10 +// 是否显示重新登录
  11 +let isReloginShow;
10 12
11 axios.defaults.headers['Content-Type'] = 'application/json;charset=utf-8' 13 axios.defaults.headers['Content-Type'] = 'application/json;charset=utf-8'
12 // 创建axios实例 14 // 创建axios实例
@@ -48,16 +50,25 @@ service.interceptors.response.use(res => { @@ -48,16 +50,25 @@ service.interceptors.response.use(res => {
48 return res.data 50 return res.data
49 } 51 }
50 if (code === 401) { 52 if (code === 401) {
  53 + if (!isReloginShow) {
  54 + isReloginShow = true;
51 MessageBox.confirm('登录状态已过期,您可以继续留在该页面,或者重新登录', '系统提示', { 55 MessageBox.confirm('登录状态已过期,您可以继续留在该页面,或者重新登录', '系统提示', {
52 confirmButtonText: '重新登录', 56 confirmButtonText: '重新登录',
53 cancelButtonText: '取消', 57 cancelButtonText: '取消',
54 type: 'warning' 58 type: 'warning'
55 } 59 }
56 ).then(() => { 60 ).then(() => {
  61 + isReloginShow = false;
57 store.dispatch('LogOut').then(() => { 62 store.dispatch('LogOut').then(() => {
  63 + // 如果是登录页面不需要重新加载
  64 + if (window.location.hash.indexOf("#/login") != 0) {
58 location.href = '/index'; 65 location.href = '/index';
  66 + }
59 }) 67 })
60 - }).catch(() => {}); 68 + }).catch(() => {
  69 + isReloginShow = false;
  70 + });
  71 + }
61 return Promise.reject('无效的会话,或者会话已过期,请重新登录。') 72 return Promise.reject('无效的会话,或者会话已过期,请重新登录。')
62 } else if (code === 500) { 73 } else if (code === 500) {
63 Message({ 74 Message({