hookehuyr

fix(MessageDetail): 修复消息列表滚动和输入框间距问题

调整滚动逻辑确保消息列表能正确滚动到底部
添加输入框光标间距避免键盘遮挡
关闭对话框时重置相关状态
{"projectName":"trae_jgdl_l75p"}
\ No newline at end of file
......@@ -69,6 +69,7 @@
placeholder="请输入回复内容..."
:rows="2"
:max-length="500"
:cursorSpacing="100"
class="message-input"
@focus="handleInputFocus"
/>
......@@ -249,10 +250,13 @@ const sendMessage = async () => {
*/
const scrollToBottom = () => {
if (messages.value.length > 0) {
// 使用 setTimeout 确保 DOM 更新完成后再滚动
setTimeout(() => {
scrollIntoView.value = `msg-${messages.value.length - 1}`
}, 100)
// 先重置 scrollIntoView,然后设置新值确保滚动触发
scrollIntoView.value = ''
nextTick(() => {
setTimeout(() => {
scrollIntoView.value = `msg-${messages.value.length - 1}`
}, 100)
})
}
}
......@@ -271,6 +275,10 @@ const handleInputFocus = () => {
const handleClose = () => {
visible.value = false
inputMessage.value = ''
// 重置滚动相关状态
scrollTop.value = 0
scrollIntoView.value = ''
messages.value = []
emit('close')
}
......