【代码评审】商城:在线客服

pull/584/MERGE
YunaiV 2024-11-09 19:10:46 +08:00
parent e4b57bd8c0
commit 8b0778ca0c
1 changed files with 10 additions and 4 deletions

View File

@ -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 @puhui9991逻辑上先按照置顶、再按照最后消息时间2感觉写的有一丢丢小复杂发给大模型看看有没可能简化哈。
this.conversationList.sort((obj1, obj2) => {
// 如果 obj1.adminPinned 为 trueobj2.adminPinned 为 falseobj1 应该排在前面
if (obj1.adminPinned && !obj2.adminPinned) return -1
if (obj1.adminPinned && !obj2.adminPinned) {
return -1
}
// 如果 obj1.adminPinned 为 falseobj2.adminPinned 为 trueobj2 应该排在前面
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) {