From 17b4decb19e20051d35e8e3d339e62cf6404d845 Mon Sep 17 00:00:00 2001 From: zoujing Date: Wed, 6 Aug 2025 19:10:28 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=8F=91=E9=80=81=E6=B6=88=E6=81=AF?= =?UTF-8?q?=E5=90=8E=E7=9A=84=E6=B8=85=E9=99=A4=E9=97=AE=E9=A2=98=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/chat/ChatInputArea.vue | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/pages/chat/ChatInputArea.vue b/pages/chat/ChatInputArea.vue index 74932fe..fb3a386 100644 --- a/pages/chat/ChatInputArea.vue +++ b/pages/chat/ChatInputArea.vue @@ -85,16 +85,16 @@ import { ref, watch, nextTick, onMounted, onUnmounted } from 'vue' const props = defineProps({ - inputMessage: String, + modelValue: String, holdKeyboard: Boolean, isSessionActive: Boolean, stopRequest: Function }) -const emit = defineEmits(['update:inputMessage', 'send', 'noHideKeyboard', 'keyboardShow', 'keyboardHide', 'sendVoice']) +const emit = defineEmits(['update:modelValue', 'send', 'noHideKeyboard', 'keyboardShow', 'keyboardHide', 'sendVoice']) const textareaRef = ref(null) const placeholder = ref('快告诉朵朵您在想什么~') -const inputMessage = ref(props.inputMessage || '') +const inputMessage = ref(props.modelValue || '') const isFocused = ref(false) const keyboardHeight = ref(0) const isVoiceMode = ref(false) @@ -107,10 +107,18 @@ const isSlideToText = ref(false) // 保持和父组件同步 -watch(() => props.inputMessage, (val) => { +watch(() => props.modelValue, (val) => { inputMessage.value = val }) +// 当子组件的 inputMessage 变化时,通知父组件(但要避免循环更新) +watch(inputMessage, (val) => { + // 只有当值真正不同时才emit,避免循环更新 + if (val !== props.modelValue) { + emit('update:modelValue', val) + } +}) + // 切换语音/文本模式 const toggleVoiceMode = () => { isVoiceMode.value = !isVoiceMode.value