feat(@vben/web-antd): 优化登录失败问题

- 增加登录失败刷新token
This commit is contained in:
Kven 2025-06-17 15:41:52 +08:00
parent 09eb944612
commit 3781e6cd47
2 changed files with 9 additions and 3 deletions

View File

@ -77,6 +77,12 @@ export const useAuthStore = defineStore('auth', () => {
});
}
}
} catch (error: any) {
if (error.code === 401) {
const { csrf } = await getUserInfoApi(); // 获取新的 token
setToken(csrf.token); // 更新 CSRF token
accessStore.setAccessToken(csrf.token);
}
} finally {
loginLoading.value = false;
}

View File

@ -238,8 +238,8 @@ const startFetching = async () => {
}
conversationId.value = res.conversationId;
const { filename, url } = extractDocxInfo(res.answer);
if (res.messageFiles) {
const { id, url } = res.messageFiles[0];
if (res.answer) {
// const { id, url } = res.messageFiles[0];
resultItems.value.push({
key: resultItems.value.length + 1,
role: 'ai',
@ -265,7 +265,7 @@ const startFetching = async () => {
onClick: () => {
const link = document.createElement('a');
link.href = url;
link.download = id;
link.download = filename;
document.body.append(link);
link.click();
link.remove();