From 71541f9a22a7f5eb966f581b2ca19ff5846adaa4 Mon Sep 17 00:00:00 2001 From: Nelson <1475262689@qq.com> Date: Tue, 11 Aug 2026 17:49:00 +0800 Subject: [PATCH] fix: refresh voice config only on chat lifecycle --- .../apps/user-client/src/App.vue | 4 +++- .../user-client/src/components/ChatComposer.vue | 17 +---------------- 2 files changed, 4 insertions(+), 17 deletions(-) diff --git a/ai_knowledge_base_v2/apps/user-client/src/App.vue b/ai_knowledge_base_v2/apps/user-client/src/App.vue index fac9103..01ec3b1 100644 --- a/ai_knowledge_base_v2/apps/user-client/src/App.vue +++ b/ai_knowledge_base_v2/apps/user-client/src/App.vue @@ -15,6 +15,7 @@ import type { ChatMessage as ApiMessage, ChatSession, PeriodicReport, PracticeRe const user = ref(null); const sessions = ref([]); const activeSessionId = ref(null); +const composerKey = ref(0); const messages = ref([]); const drawerOpen = ref(false); const sending = ref(false); @@ -127,6 +128,7 @@ async function loadSessions() { async function createSession() { if (sessionOperationPending.value) return; + composerKey.value += 1; const existingBlank = sessions.value.find((session) => session.messageCount === 0); if (existingBlank) { await selectSession(existingBlank.id); @@ -643,7 +645,7 @@ async function copyText(text: string) { @retry="retryMessage" @feedback="openFeedback" /> - + import { Mic, Send, Square, X } from "@lucide/vue"; -import { nextTick, onMounted, onUnmounted, ref } from "vue"; +import { nextTick, onMounted, ref } from "vue"; import { useVoiceRecorder } from "../composables/useVoiceRecorder"; import { api, transcribeVoice } from "../services/api"; @@ -47,23 +47,8 @@ async function refreshVoiceConfig() { } } -function refreshVoiceConfigWhenVisible() { - if (document.visibilityState === "visible") void refreshVoiceConfig(); -} - -let voiceConfigTimer: number | undefined; - onMounted(() => { void refreshVoiceConfig(); - window.addEventListener("focus", refreshVoiceConfigWhenVisible); - document.addEventListener("visibilitychange", refreshVoiceConfigWhenVisible); - voiceConfigTimer = window.setInterval(refreshVoiceConfigWhenVisible, 30_000); -}); - -onUnmounted(() => { - window.removeEventListener("focus", refreshVoiceConfigWhenVisible); - document.removeEventListener("visibilitychange", refreshVoiceConfigWhenVisible); - if (voiceConfigTimer !== undefined) window.clearInterval(voiceConfigTimer); }); function resize() {