From 8b0778ca0cdfa4f76f188082a4daeea2147be398 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Sat, 9 Nov 2024 19:10:46 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E4=BB=A3=E7=A0=81=E8=AF=84=E5=AE=A1?= =?UTF-8?q?=E3=80=91=E5=95=86=E5=9F=8E=EF=BC=9A=E5=9C=A8=E7=BA=BF=E5=AE=A2?= =?UTF-8?q?=E6=9C=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/store/modules/mall/kefu.ts | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/store/modules/mall/kefu.ts b/src/store/modules/mall/kefu.ts index fae52f70..16f1dfc2 100644 --- a/src/store/modules/mall/kefu.ts +++ b/src/store/modules/mall/kefu.ts @@ -23,12 +23,13 @@ export const useMallKefuStore = defineStore('mall-kefu', { } }, actions: { - //======================= 会话消息相关 ======================= + // ======================= 会话消息相关 ======================= /** 缓存历史消息 */ saveMessageList(conversationId: number, messageList: KeFuMessageRespVO[]) { this.conversationMessageList.set(conversationId, messageList) }, - //======================= 会话相关 ======================= + + // ======================= 会话相关 ======================= /** 加载会话缓存列表 */ async setConversationList() { this.conversationList = await KeFuConversationApi.getConversationList() @@ -62,11 +63,16 @@ export const useMallKefuStore = defineStore('mall-kefu', { } }, conversationSort() { + // TODO @puhui999:1)逻辑上,先按照置顶、再按照最后消息时间;2)感觉写的有一丢丢小复杂,发给大模型,看看有没可能简化哈。 this.conversationList.sort((obj1, obj2) => { // 如果 obj1.adminPinned 为 true,obj2.adminPinned 为 false,obj1 应该排在前面 - if (obj1.adminPinned && !obj2.adminPinned) return -1 + if (obj1.adminPinned && !obj2.adminPinned) { + return -1 + } // 如果 obj1.adminPinned 为 false,obj2.adminPinned 为 true,obj2 应该排在前面 - if (!obj1.adminPinned && obj2.adminPinned) return 1 + if (!obj1.adminPinned && obj2.adminPinned) { + return 1 + } // 如果 obj1.adminPinned 和 obj2.adminPinned 都为 true,比较 adminUnreadMessageCount 的值 if (obj1.adminPinned && obj2.adminPinned) {