diff --git a/uni_modules/uni-im/changelog.md b/uni_modules/uni-im/changelog.md
index 75fad71beb9dd48f0abf2cb8f026bd87553da0fc..0fd63697684de8bfec3b2f62a8892cbbc53f76b9 100644
--- a/uni_modules/uni-im/changelog.md
+++ b/uni_modules/uni-im/changelog.md
@@ -1,3 +1,5 @@
+## 2.0.10(2023-05-25)
+- 修复 Vue3-web-pc端 敲完回车会先执行换行再发送消息的问题
## 2.0.9(2023-05-25)
- 修复 因为`2.0.8`优化sqlite,引起的web端报`ReferenceError: sqlite is not defined`的问题
## 2.0.8(2023-05-24)
diff --git a/uni_modules/uni-im/common/utils.js b/uni_modules/uni-im/common/utils.js
index fe71699215b23af065a5a5df516d1c1d4ce50901..7e3c256c26595e5f7f9330ff9de8513df556cbda 100644
--- a/uni_modules/uni-im/common/utils.js
+++ b/uni_modules/uni-im/common/utils.js
@@ -32,7 +32,7 @@ let appIsShow = true;
let getCloudMsgIng = false
export default {
init() {
- // #ifdef APP-NVUE
+ // #ifdef APP
getApp().globalData.sqlite = sqlite
// #endif
diff --git a/uni_modules/uni-im/components/uni-im-msg/uni-im-msg.vue b/uni_modules/uni-im/components/uni-im-msg/uni-im-msg.vue
index fcf22ceece0341db3c73078c2dd120149ac567b2..9d273144f6d5a68344d416bff41cf4ccd10f706f 100644
--- a/uni_modules/uni-im/components/uni-im-msg/uni-im-msg.vue
+++ b/uni_modules/uni-im/components/uni-im-msg/uni-im-msg.vue
@@ -502,7 +502,7 @@
}
},
destroyed(){
- // console.log('uni-im-msg-destroyed');
+ console.log('uni-im-msg-destroyed');
audioContext.offPlay(this.onPlay);
audioContext.offPause(this.soundPlayEnd);
audioContext.offStop(this.soundPlayEnd);
diff --git a/uni_modules/uni-im/package.json b/uni_modules/uni-im/package.json
index 5b7e6551c73625dd744d26ec042ed2d3827cf06c..9ccb7dd2ea62d8b36741007fec625ec1b4e63468 100644
--- a/uni_modules/uni-im/package.json
+++ b/uni_modules/uni-im/package.json
@@ -1,7 +1,7 @@
{
"id": "uni-im",
"displayName": "uni-im",
- "version": "2.0.9",
+ "version": "2.0.10",
"description": "uni-im是云端一体的、全平台的、免费的、开源即时通讯系统",
"keywords": [
"im,即时通讯,客服,聊天"
diff --git a/uni_modules/uni-im/pages/chat/chat.nvue b/uni_modules/uni-im/pages/chat/chat.nvue
index 336a9c8c8689c3093c50be9b4ab89859f434dadf..223abb18f2e653b890279b0aee2a9e6effc9e403 100644
--- a/uni_modules/uni-im/pages/chat/chat.nvue
+++ b/uni_modules/uni-im/pages/chat/chat.nvue
@@ -34,51 +34,53 @@
{{getNicknameByUid(msgList[answerMsgIndex].from_uid)}}:{{msgList[answerMsgIndex].body}}
-
-
-
-
-
-
-
-
-
-
- {{getNicknameByUid(msgList[answerMsgIndex].from_uid)}}:{{msgList[answerMsgIndex].body}}
-
-
-
-
-
- 发送
-
-
-
-
-
-
- {{uniCodeEmoji}}
-
-
-
+
+
+
+
+
+
+
+
+
+
+ {{getNicknameByUid(msgList[answerMsgIndex].from_uid)}}:{{msgList[answerMsgIndex].body}}
+
+
+
+
+
+ 发送
+
+
+
+
+
+
+ {{uniCodeEmoji}}
+
+
+
+
@@ -411,7 +413,7 @@
// #ifdef H5 && VUE3
//获得消息输入框对象
let adjunctKeydown = false
- const textareaDom = document.querySelector('.textarea-box textarea');
+ const textareaDom = document.querySelector('.pc textarea');
if (textareaDom) {
//键盘按下时
textareaDom.onkeydown = e => {
@@ -421,10 +423,7 @@
adjunctKeydown = true;
}
if (e.keyCode == 13 && !adjunctKeydown) {
- // 延迟兼容 v-model的时机小于onkeydown的问题
- setTimeout(()=> {
- this.beforeSendMsg();
- }, 100);
+ this.beforeSendMsg();
}
};
textareaDom.onkeyup = e => {
@@ -687,8 +686,17 @@
}
}
// 如果是文本类型需要做一些处理
- if(data.type == 'text'){
- //清除空格
+ if(data.type == 'text'){
+ // #ifdef H5
+ const textareaDom = document.querySelector('.pc textarea') || document.querySelector('.textarea-box textarea')
+ this.chatText = textareaDom.value
+ textareaDom.disabled = true
+ setTimeout(()=> {
+ textareaDom.disabled = false
+ this.isFocus = true
+ }, 0);
+ // #endif
+ //清除空格
data.body = this.chatText.trim();
// console.log('data.body',data.body);
// 阻止发送空消息
@@ -700,12 +708,12 @@
}
// 在下一个事件循环 清除输入框的文本内容
- // 注意:为兼容web-pc端 这里必须用 setTimeout,0
- setTimeout(e => {
+ // 注意:为兼容web-pc端 这里必须用 setTimeout,0
+ this.$nextTick(e => {
this.chatText = '';
this.textareaHeight = 26;
this.answerMsgIndex = false
- },0);
+ });
// 当消息是否为 code类型开启时设置 -- 快速实现,临时方案 后续会优化
if(this.isCodeText){