优化发送消息功能
This commit is contained in:
@@ -403,16 +403,18 @@ export default {
|
|||||||
this.$set(this.contactMessages, this.currentContact.contactName, []);
|
this.$set(this.contactMessages, this.currentContact.contactName, []);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 新消息
|
||||||
const newMessage = {
|
const newMessage = {
|
||||||
senderName: this.currentUser.username,
|
senderName: this.currentUser.username,
|
||||||
receiverName: this.currentContact.contactName,
|
receiverName: this.currentContact.contactName,
|
||||||
content: content,
|
content: content,
|
||||||
|
createdAt: new Date()
|
||||||
};
|
};
|
||||||
|
|
||||||
sendMessage(newMessage)
|
sendMessage(newMessage)
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
console.log("发送消息成功", response.data);
|
console.log("发送消息成功", response.data);
|
||||||
this.contactMessages[this.currentContact.contactName].push({
|
this.contactMessages.push({
|
||||||
...newMessage,
|
...newMessage,
|
||||||
from: "me",
|
from: "me",
|
||||||
});
|
});
|
||||||
@@ -432,6 +434,7 @@ export default {
|
|||||||
|
|
||||||
this.recentChats.splice(index, 1);
|
this.recentChats.splice(index, 1);
|
||||||
this.recentChats.unshift(chat);
|
this.recentChats.unshift(chat);
|
||||||
|
console.log(this.recentChats)
|
||||||
} else {
|
} else {
|
||||||
// 没有找到这条数据,直接添加到数组最前面
|
// 没有找到这条数据,直接添加到数组最前面
|
||||||
this.recentChats.unshift({
|
this.recentChats.unshift({
|
||||||
|
|||||||
Reference in New Issue
Block a user