feat: 修复发送消息后的键盘处理

This commit is contained in:
2026-05-14 15:20:34 +08:00
parent e453a78212
commit 405be2ca99
2 changed files with 42 additions and 19 deletions

View File

@@ -381,7 +381,10 @@ const hideKeyboardByScroll = () => {
holdKeyboardFlag.value = true;
isKeyboardShow.value = false;
if (inputAreaRef.value && inputAreaRef.value.blurInput) {
if (
inputAreaRef.value &&
typeof inputAreaRef.value.blurInput === "function"
) {
inputAreaRef.value.blurInput();
}
@@ -394,6 +397,21 @@ const hideKeyboardByScroll = () => {
// #endif
};
const hideKeyboardAfterSend = () => {
holdKeyboard.value = false;
holdKeyboardFlag.value = true;
isKeyboardShow.value = false;
if (
inputAreaRef.value &&
typeof inputAreaRef.value.blurInput === "function"
) {
inputAreaRef.value.blurInput();
} else {
uni.hideKeyboard();
}
};
const handleScrollAreaTouchStart = () => {
lastScrollTouchAt = Date.now();
hideKeyboardByScroll();
@@ -476,7 +494,6 @@ const handleReplyInstruct = async (item) => {
const sendMessageAction = (inputText) => {
console.log("输入消息:", inputText);
if (!inputText.trim()) return;
handleNoHideKeyboard();
// 发送消息时,强制开启自动滚动
isAutoScroll.value = true;
@@ -484,12 +501,7 @@ const sendMessageAction = (inputText) => {
resetMessageState();
sendMessage(inputText);
// 发送消息后保持键盘状态
if (holdKeyboard.value && inputAreaRef.value) {
setTimeout(() => {
inputAreaRef.value.focusInput();
}, 100);
}
hideKeyboardAfterSend();
setTimeoutScrollToBottom(true);
};