feat: 添加网络错误处理,退出登录状态
This commit is contained in:
@@ -3,7 +3,7 @@ import {
|
|||||||
CACHE_LOCAL_I18N,
|
CACHE_LOCAL_I18N,
|
||||||
CACHE_SESSION_CRYPTO_API,
|
CACHE_SESSION_CRYPTO_API,
|
||||||
} from '@/constants/cache-keys-constants';
|
} from '@/constants/cache-keys-constants';
|
||||||
import { RESULT_CODE_SUCCESS } from '@/constants/result-constants';
|
import { RESULT_CODE_EXCEPTION, RESULT_CODE_SUCCESS } from '@/constants/result-constants';
|
||||||
import { delAccessToken, delRefreshToken } from '@/plugins/auth-token';
|
import { delAccessToken, delRefreshToken } from '@/plugins/auth-token';
|
||||||
import { parseUrlPath } from '@/plugins/file-static-url';
|
import { parseUrlPath } from '@/plugins/file-static-url';
|
||||||
import { localGet, localSet } from '@/utils/cache-local-utils';
|
import { localGet, localSet } from '@/utils/cache-local-utils';
|
||||||
@@ -132,6 +132,12 @@ const useAppStore = defineStore('app', {
|
|||||||
localSet(CACHE_LOCAL_I18N, this.i18nDefault);
|
localSet(CACHE_LOCAL_I18N, this.i18nDefault);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// 网络错误时退出登录状态
|
||||||
|
if (res.code === RESULT_CODE_EXCEPTION) {
|
||||||
|
delAccessToken();
|
||||||
|
delRefreshToken();
|
||||||
|
window.location.reload();
|
||||||
|
}
|
||||||
return res;
|
return res;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import {
|
|||||||
setRefreshToken,
|
setRefreshToken,
|
||||||
} from '@/plugins/auth-token';
|
} from '@/plugins/auth-token';
|
||||||
import { defineStore } from 'pinia';
|
import { defineStore } from 'pinia';
|
||||||
import { RESULT_CODE_SUCCESS } from '@/constants/result-constants';
|
import { RESULT_CODE_EXCEPTION, RESULT_CODE_SUCCESS } from '@/constants/result-constants';
|
||||||
import { parseUrlPath } from '@/plugins/file-static-url';
|
import { parseUrlPath } from '@/plugins/file-static-url';
|
||||||
|
|
||||||
/**用户信息类型 */
|
/**用户信息类型 */
|
||||||
@@ -154,6 +154,12 @@ const useUserStore = defineStore('user', {
|
|||||||
this.forcePasswdChange = true;
|
this.forcePasswdChange = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// 网络错误时退出登录状态
|
||||||
|
if (res.code === RESULT_CODE_EXCEPTION) {
|
||||||
|
delAccessToken();
|
||||||
|
delRefreshToken();
|
||||||
|
window.location.reload();
|
||||||
|
}
|
||||||
return res;
|
return res;
|
||||||
},
|
},
|
||||||
// 退出系统
|
// 退出系统
|
||||||
|
|||||||
Reference in New Issue
Block a user