From 6cebdc7c71b4a26e21152ba125edb3f61fac577a Mon Sep 17 00:00:00 2001 From: Seven <1530011482@qq.com> Date: Mon, 21 Sep 2026 11:20:36 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=87=E6=8D=A2=E8=81=94=E7=B3=BB=E4=BA=BA?= =?UTF-8?q?=E6=97=B6=E7=9A=84UI=E4=BC=98=E5=8C=96=E5=92=8C=E6=B6=88?= =?UTF-8?q?=E6=81=AF=E8=8E=B7=E5=8F=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/index/ChatPage.vue | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/src/pages/index/ChatPage.vue b/src/pages/index/ChatPage.vue index e7db53a..fe35e18 100644 --- a/src/pages/index/ChatPage.vue +++ b/src/pages/index/ChatPage.vue @@ -148,7 +148,7 @@
-
-
💬
-
-
@@ -282,7 +274,12 @@ export default { // 切换菜单 changeMenu(menu) { this.activeMenu = menu; + this.currentContact = null; + if(menu === "contacts") { + this.getContactList(); + } }, + // 退出登录 logout() { // 清除 token 和用户信息 @@ -290,6 +287,7 @@ export default { this.$store.commit("SET_USERNAME", ""); this.$router.push("/login"); }, + // 获取当前登录用户信息 getCurrentUser() { // 获取当前登录用户信息 @@ -303,6 +301,7 @@ export default { this.$router.push("/login"); }); }, + // 获取最近消息列表 getRecentMessageList() { getRecentMessages() @@ -315,6 +314,7 @@ export default { this.$message.error("获取消息列表失败"); }); }, + // 选择联系人 selectContact(contact) { this.currentContact = contact; @@ -327,12 +327,14 @@ export default { this.scrollToBottom(); }); }, + // 选择最近一个联系人 selectFirstContact() { if (!this.currentContact && this.recentChats.length > 0) { this.selectContact(this.recentChats[0]); } }, + // 获取当前联系人的消息列表 getContactMessageList(contactName, limit) { // 获取当前联系人的消息列表 @@ -362,6 +364,8 @@ export default { this.$message.error("获取消息列表失败"); }); }, + + // 获取联系人列表 getContactList() { getContactInfo() .then((response) => { @@ -369,14 +373,13 @@ export default { ...contact, unread: contact.unread || 0, })); - console.log("contactList", this.contactList); - this.selectFirstContact(); }) .catch((error) => { console.error(error); this.$message.error("获取联系人信息失败"); }); }, + // 获取最后一条消息 getLastMessage(contactName) { const messageList = this.contactMessages[contactName];