refactor(websocket/wechat): 优化客服列表排序并简化初始化逻辑

- 在msgManage.ts中按在线状态排序客服列表
- 在main.ts中简化初始化逻辑,使用getAgentList和getChatroomList替代原有复杂逻辑
- 在api.ts中新增相关API接口并统一使用request2
This commit is contained in:
2025-09-15 15:21:24 +08:00
parent a270b8ce3e
commit c91e54370f
3 changed files with 81 additions and 66 deletions

View File

@@ -23,6 +23,14 @@ const messageHandlers: Record<string, MessageHandler> = {
kfUserList.forEach(kfUser => {
kfUser.isOnline = wechatAccountsAliveStatus[kfUser.id];
});
// 按在线状态排序,在线的排在前面
kfUserList.sort((a, b) => {
if (a.isOnline && !b.isOnline) return -1;
if (!a.isOnline && b.isOnline) return 1;
return 0;
});
asyncKfUserList(kfUserList);
},
// 发送消息响应