From 32854397fbeb89ef5b09d5e850075d921b5997de Mon Sep 17 00:00:00 2001 From: Lishiling Date: Sat, 21 Feb 2026 20:44:32 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E5=88=A0=E9=99=A4=E6=89=80=E6=9C=89?= =?UTF-8?q?=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dashboard/src/components/chat/Chat.vue | 10 --- .../src/components/chat/StandaloneChat.vue | 83 +------------------ dashboard/src/composables/useSessions.ts | 65 +-------------- 3 files changed, 5 insertions(+), 153 deletions(-) diff --git a/dashboard/src/components/chat/Chat.vue b/dashboard/src/components/chat/Chat.vue index 2bbd96ba9..71e46e690 100644 --- a/dashboard/src/components/chat/Chat.vue +++ b/dashboard/src/components/chat/Chat.vue @@ -228,9 +228,6 @@ const props = withDefaults(defineProps(), { chatboxMode: false }); -// TODO: Remove debug log -console.warn('[Chat] component loaded', { chatboxMode: props.chatboxMode }); - const router = useRouter(); const route = useRoute(); const { t } = useI18n(); @@ -586,11 +583,6 @@ async function handleSendMessage() { const currentProjectId = selectedProjectId.value; // 保存当前项目ID if (isCreatingNewSession) { - // TODO: Remove debug log - console.warn('[Chat] No active session; calling newSession() before send', { - selectedProjectId: currentProjectId, - currSessionId: currSessionId.value - }); await newSession(); // 如果在项目视图中创建新会话,立即退出项目视图 @@ -683,8 +675,6 @@ watch(sessions, (newSessions) => { }); onMounted(() => { - // TODO: Remove debug log - console.warn('[Chat] mounted'); checkMobile(); window.addEventListener('resize', checkMobile); getSessions(); diff --git a/dashboard/src/components/chat/StandaloneChat.vue b/dashboard/src/components/chat/StandaloneChat.vue index 68fc91a65..db762dabf 100644 --- a/dashboard/src/components/chat/StandaloneChat.vue +++ b/dashboard/src/components/chat/StandaloneChat.vue @@ -83,8 +83,6 @@ const props = withDefaults(defineProps(), { const { t } = useI18n(); const { error: showError } = useToast(); -// TODO: Remove debug log -console.warn('[StandaloneChat] component loaded', { configId: props.configId }); // UI 状态 const imagePreviewDialog = ref(false); @@ -97,107 +95,32 @@ const getCurrentSession = computed(() => null); // 独立测试模式不需要 async function bindConfigToSession(sessionId: string) { const confId = (props.configId || '').trim(); if (!confId || confId === 'default') { - // TODO: Remove debug log - console.warn('[StandaloneChat] Skip binding config to session', { - sessionId, - confId, - reason: !confId ? 'empty_configId' : 'default_configId' - }); return; } const umoDetails = buildWebchatUmoDetails(sessionId, false); - // TODO: Remove debug log - console.warn('[StandaloneChat] Binding config to session', { - sessionId, - confId, - localStorageUser: localStorage.getItem('user'), - umo: umoDetails.umo, - username: umoDetails.username, - sessionKey: umoDetails.sessionKey - }); - - const payload = { + await axios.post('/api/config/umo_abconf_route/update', { umo: umoDetails.umo, conf_id: confId - }; - - // TODO: Remove debug log - console.warn('[StandaloneChat] POST /api/config/umo_abconf_route/update', payload); - - const updateRes = await axios.post('/api/config/umo_abconf_route/update', payload); - - // TODO: Remove debug log - console.warn('[StandaloneChat] Route update response', { - umo: payload.umo, - status: updateRes.status, - data: updateRes.data }); - - try { - const routesRes = await axios.get('/api/config/umo_abconf_routes'); - const routing = routesRes.data?.data?.routing || {}; - const boundConfId = routing[umoDetails.umo]; - const related = Object.entries(routing) - .filter(([umo]) => typeof umo === 'string' && umo.includes(sessionId)) - .map(([umo, id]) => ({ umo, confId: id })); - - // TODO: Remove debug log - console.warn('[StandaloneChat] Routing table after update', { - totalEntries: Object.keys(routing).length, - selectedUmo: umoDetails.umo, - boundConfId, - relatedEntries: related - }); - } catch (err) { - const axiosErr = err as any; - // TODO: Remove debug log - console.warn('[StandaloneChat] Failed to fetch routing table after update', { - message: axiosErr?.message, - status: axiosErr?.response?.status, - data: axiosErr?.response?.data - }); - } } async function newSession() { try { - // TODO: Remove debug log - console.warn('[StandaloneChat] Creating new session', { configId: props.configId }); - const response = await axios.get('/api/chat/new_session'); const sessionId = response.data.data.session_id; - // TODO: Remove debug log - console.warn('[StandaloneChat] New session created', { - sessionId, - platformId: response.data.data.platform_id - }); - - // Bind the config before activating the session in the UI. try { await bindConfigToSession(sessionId); } catch (err) { - const axiosErr = err as any; - // TODO: Remove debug log - console.error('[StandaloneChat] Failed to bind config to session', { - sessionId, - configId: props.configId, - message: axiosErr?.message, - status: axiosErr?.response?.status, - data: axiosErr?.response?.data - }); + console.error('Failed to bind config to session', err); } currSessionId.value = sessionId; - // TODO: Remove debug log - console.warn('[StandaloneChat] Session activated in UI', { sessionId }); - return sessionId; } catch (err) { - // TODO: Remove debug log console.error(err); throw err; } @@ -314,8 +237,6 @@ async function handleSendMessage() { } onMounted(async () => { - // TODO: Remove debug log - console.warn('[StandaloneChat] mounted'); // 独立模式在挂载时创建新会话 try { await newSession(); diff --git a/dashboard/src/composables/useSessions.ts b/dashboard/src/composables/useSessions.ts index 33e22b3fc..decde8d9e 100644 --- a/dashboard/src/composables/useSessions.ts +++ b/dashboard/src/composables/useSessions.ts @@ -20,9 +20,6 @@ export function useSessions(chatboxMode: boolean = false) { const currSessionId = ref(''); const pendingSessionId = ref(null); - // TODO: Remove debug log - console.warn('[useSessions] composable initialized', { chatboxMode }); - // 编辑标题相关 const editTitleDialog = ref(false); const editingTitle = ref(''); @@ -66,79 +63,23 @@ export function useSessions(chatboxMode: boolean = false) { async function newSession() { try { - // TODO: Remove debug log - console.warn('[useSessions] newSession() entered', { chatboxMode }); - const selectedConfigId = getStoredSelectedChatConfigId(); - // TODO: Remove debug log - console.warn('[useSessions] Stored chat selected config', { selectedConfigId }); const response = await axios.get('/api/chat/new_session'); const sessionId = response.data.data.session_id; const platformId = response.data.data.platform_id; - // TODO: Remove debug log - console.warn('[useSessions] New session created', { sessionId, platformId }); currSessionId.value = sessionId; if (selectedConfigId && selectedConfigId !== 'default' && platformId === 'webchat') { - const umoDetails = buildWebchatUmoDetails(sessionId, false); - - // TODO: Remove debug log - console.warn('[useSessions] Binding config to new session', { - sessionId, - selectedConfigId, - umo: umoDetails.umo, - username: umoDetails.username - }); - try { - const updateRes = await axios.post('/api/config/umo_abconf_route/update', { + const umoDetails = buildWebchatUmoDetails(sessionId, false); + await axios.post('/api/config/umo_abconf_route/update', { umo: umoDetails.umo, conf_id: selectedConfigId }); - - // TODO: Remove debug log - console.warn('[useSessions] Route update response', { - status: updateRes.status, - data: updateRes.data - }); - - try { - const routesRes = await axios.get('/api/config/umo_abconf_routes'); - const routing = routesRes.data?.data?.routing || {}; - // TODO: Remove debug log - console.warn('[useSessions] Routing table check', { - umo: umoDetails.umo, - boundConfId: routing[umoDetails.umo], - totalEntries: Object.keys(routing).length - }); - } catch (err) { - const axiosErr = err as any; - // TODO: Remove debug log - console.warn('[useSessions] Failed to fetch routing table after update', { - message: axiosErr?.message, - status: axiosErr?.response?.status, - data: axiosErr?.response?.data - }); - } } catch (err) { - const axiosErr = err as any; - // TODO: Remove debug log - console.error('[useSessions] Failed to bind config to session', { - sessionId, - selectedConfigId, - message: axiosErr?.message, - status: axiosErr?.response?.status, - data: axiosErr?.response?.data - }); + console.error('Failed to bind config to session', err); } - } else { - // TODO: Remove debug log - console.warn('[useSessions] Skip binding config to new session', { - sessionId, - selectedConfigId, - platformId - }); } // 更新 URL