1.修复问题同时打开多个标签页,退出登录,其它几个标签页并没有退出登录

2.点击智能体时,若当前已经打开智能体标签,则不会再打开新标签页
This commit is contained in:
hugo committed 2026-05-26 20:58:11 +08:00
1 parent 3642ed8529
commit 63ea9d7ed7
6 files changed
+201 -19

No files matched your search

+25 -10
View File
@@ -4,7 +4,7 @@
* 文件用途:用户工作台,支持自定义布局、收藏、嵌入 Agent
* 引用文件:vue, vue-router, lucide-vue-next, 后端 /api/user 接口
*/
import { ref, onMounted, computed, watch, nextTick } from 'vue';
import { ref, onMounted, onBeforeUnmount, computed, watch, nextTick } from 'vue';
import { useRouter, useRoute } from 'vue-router';
import { useI18n } from 'vue-i18n';
import { config } from '../config';
@@ -24,8 +24,9 @@ import {
type WecomLoginDialogContent,
type WecomMatchField,
} from '../utils/wecom';
import { getAuthHeaders, getStoredAuthUser, saveAuthUser } from '../utils/auth';
import { getAuthHeaders, getStoredAuthUser, saveAuthUser, logoutAuth } from '../utils/auth';
import { getLastChatAgentId } from '../utils/lastChatAgent';
import { openAgentChatTab } from '../utils/agentTabs';
import {
Settings,
LayoutGrid,
@@ -405,7 +406,10 @@ const loadAuthUser = () => {
stored = sessionStorage.getItem('hxops_user');
}
if (!stored) return;
if (!stored) {
currentUser.value = null;
return;
}
try {
const user = getStoredAuthUser();
@@ -847,10 +851,7 @@ const mobileTabTitle = computed(() => {
return t('workspace.mobileTabs.applications');
});
const handleLogout = () => {
localStorage.removeItem('hxops_user');
sessionStorage.removeItem('hxops_user');
sessionStorage.removeItem('hxops_wecom_state');
const applyLoggedOutState = () => {
currentUser.value = null;
agents.value = [];
quickQuestions.value = [];
@@ -858,9 +859,18 @@ const handleLogout = () => {
embeddedAgents.value = [];
userReport.value = null;
fetchPublicAgents();
};
const handleLogout = () => {
logoutAuth();
applyLoggedOutState();
router.push('/');
};
const onAuthLogout = () => {
applyLoggedOutState();
};
const captureOriginalProfile = () => {
originalProfile.value = { ...profileUser.value };
};
@@ -1178,7 +1188,7 @@ const navigateToChat = (id: number) => {
return;
}
const url = router.resolve(`/chat/${id}`).href;
window.open(url, '_blank');
openAgentChatTab(url, id);
};
const navigateWithQuickQuestion = (agentId: number, question: string) => {
@@ -1191,7 +1201,7 @@ const navigateWithQuickQuestion = (agentId: number, question: string) => {
path: `/chat/${agentId}`,
query: { preset: question },
}).href;
window.open(url, '_blank');
openAgentChatTab(url, agentId);
};
const handleWecomDeeplinkContext = async () => {
@@ -1224,7 +1234,7 @@ const handleWecomDeeplinkContext = async () => {
path: `/chat/${agentId}`,
query: preset ? { preset } : {},
}).href;
window.open(url, '_blank');
openAgentChatTab(url, agentId);
}
}
@@ -1362,6 +1372,7 @@ const openAnnouncement = (ann: Announcement) => {
};
onMounted(async () => {
window.addEventListener('hxops:logout', onAuthLogout);
loadLanguagePreference();
fetchAnnouncements();
const handledCasdoor = await tryCasdoorCallbackLogin();
@@ -1392,6 +1403,10 @@ onMounted(async () => {
isLoading.value = false;
}
});
onBeforeUnmount(() => {
window.removeEventListener('hxops:logout', onAuthLogout);
});
</script>
<template>