fix: 优化登录信息查询逻辑

- 当接口返回 code 500(未找到登录信息)时,先查询登录历史
- 有登录历史数据则提示'当前会话已过期,请重新登录'
- 无登录历史数据则提示'当前未登录,请先登录'
- 在 catch 块中也设置 loginResult 为 null,确保状态一致
This commit is contained in:
Kris 2026-01-24 18:39:29 +08:00
parent ca605187c8
commit f7e6ac0e2a

View File

@ -650,11 +650,20 @@ const handleLoginTypeChange = () => {
} else {
loginResult.value = response.data;
}
} else if (response.code === 500) {
loginResult.value = null;
const historyResponse = await queryLoginHistory('source');
if (historyResponse.code === 200 && historyResponse.data && historyResponse.data.length > 0) {
ElMessage.warning('当前会话已过期,请重新登录');
} else {
ElMessage.info('当前未登录,请先登录');
}
} else {
loginResult.value = null;
}
} catch (error) {
console.warn('Auto fetch info failed:', error);
loginResult.value = null;
} finally {
currentLoading.value = false;
}