发送消息功能

This commit is contained in:
2026-09-16 22:45:03 +08:00
parent f956e60279
commit b13194ca8b
+1 -13
View File
@@ -390,14 +390,12 @@ export default {
}
const newMessage = {
id: Date.now(),
senderName: this.currentUser.username,
receiverName: this.currentContact.contactName,
content: content,
time: this.getCurrentTime(),
};
sendMessage()
sendMessage(newMessage)
.then((response) => {
console.log("发送消息成功", response.data);
this.groupedMessages[this.currentContact.contactName].push({
@@ -418,16 +416,6 @@ export default {
});
},
// 获取当前时间
getCurrentTime() {
const date = new Date();
const hours = String(date.getHours()).padStart(2, "0");
const minutes = String(date.getMinutes()).padStart(2, "0");
return `${hours}:${minutes}`;
},
// 滚动到底部
scrollToBottom() {
const messageList = this.$refs.messageList;