feat: 发送消息后的清除问题修复

This commit is contained in:
zoujing 2025-08-06 19:10:28 +08:00
parent 5292ede3c5
commit 17b4decb19

View File

@ -85,16 +85,16 @@
import { ref, watch, nextTick, onMounted, onUnmounted } from 'vue' import { ref, watch, nextTick, onMounted, onUnmounted } from 'vue'
const props = defineProps({ const props = defineProps({
inputMessage: String, modelValue: String,
holdKeyboard: Boolean, holdKeyboard: Boolean,
isSessionActive: Boolean, isSessionActive: Boolean,
stopRequest: Function 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 textareaRef = ref(null)
const placeholder = ref('快告诉朵朵您在想什么~') const placeholder = ref('快告诉朵朵您在想什么~')
const inputMessage = ref(props.inputMessage || '') const inputMessage = ref(props.modelValue || '')
const isFocused = ref(false) const isFocused = ref(false)
const keyboardHeight = ref(0) const keyboardHeight = ref(0)
const isVoiceMode = ref(false) const isVoiceMode = ref(false)
@ -107,10 +107,18 @@ const isSlideToText = ref(false)
// //
watch(() => props.inputMessage, (val) => { watch(() => props.modelValue, (val) => {
inputMessage.value = val inputMessage.value = val
}) })
// inputMessage
watch(inputMessage, (val) => {
// emit
if (val !== props.modelValue) {
emit('update:modelValue', val)
}
})
// / // /
const toggleVoiceMode = () => { const toggleVoiceMode = () => {
isVoiceMode.value = !isVoiceMode.value isVoiceMode.value = !isVoiceMode.value