fix(logout): 🐛 skip token validation during logout to prevent error loops

This commit is contained in:
Dawn
2026-01-18 02:00:19 +08:00
parent c860a140e3
commit c65c740797
2 changed files with 7 additions and 2 deletions

View File

@@ -108,6 +108,7 @@ impl ImRequestClient {
) -> Result<ApiResult<T>, anyhow::Error> {
let mut retry_count = 0;
const MAX_RETRY_COUNT: u8 = 2;
let is_logout = path == ImUrl::Logout.get_url().1;
loop {
// 使用 build_request 构建请求
@@ -127,6 +128,9 @@ impl ImRequestClient {
match result.code {
Some(406) => {
if is_logout {
return Ok(result);
}
if retry_count >= MAX_RETRY_COUNT {
return Err(anyhow::anyhow!("token过期刷新token失败"));
}
@@ -135,6 +139,9 @@ impl ImRequestClient {
continue;
}
Some(401) => {
if is_logout {
return Ok(result);
}
error!(
"{}; 方法: {}; 失败信息: {}",
&url,

View File

@@ -150,8 +150,6 @@ async function handleLogout() {
logoutSuccess = true
} catch (error) {
console.error('服务器登出失败:', error)
// 即使服务器登出失败,也继续执行本地清理,但给出警告
window.$message.warning('服务器登出失败,但本地登录状态已清除')
}
// 无论服务器登出是否成功,都执行本地状态清理