diff --git a/im-ui/src/components/chat/ChatBox.vue b/im-ui/src/components/chat/ChatBox.vue index 98a881f..99047e6 100644 --- a/im-ui/src/components/chat/ChatBox.vue +++ b/im-ui/src/components/chat/ChatBox.vue @@ -40,7 +40,7 @@
- +
发送
@@ -94,7 +94,8 @@ x: 0, y: 0 }, - showHistory: false // 是否显示历史聊天记录 + showHistory: false, // 是否显示历史聊天记录 + lockMessage: false // 是否锁定发送 } }, methods: { @@ -269,6 +270,7 @@ } // 填充对方id this.setTargetId(msgInfo, this.chat.targetId); + this.lockMessage = true; this.$http({ url: this.messageAction, method: 'post', @@ -281,11 +283,14 @@ msgInfo.sendId = this.$store.state.userStore.userInfo.id; msgInfo.selfSend = true; this.$store.commit("insertMessage", msgInfo); + }).finally(() => { + // 解除锁定 + this.lockMessage = false; // 保持输入框焦点 - this.$refs.sendBox.focus(); + this.$nextTick(() => this.$refs.sendBox.focus()); // 滚动到底部 this.scrollToBottom(); - }) + }); const e = window.event || arguments[0]; if (e.key === 'Enter' || e.code === 'Enter' || e.keyCode === 13) { e.returnValue = false;