feat(微信客服): 新增微信好友和群列表接口并优化初始化逻辑

- 添加获取微信好友列表和群列表的API接口
- 移除旧的初始化联系人列表逻辑,改用新接口
- 清理不再使用的会话过滤和排序代码
This commit is contained in:
超级老白兔
2025-09-15 15:42:05 +08:00
parent c91e54370f
commit d802b9da1f
3 changed files with 33 additions and 22 deletions

View File

@@ -12,6 +12,16 @@ import {
ChatSettings,
} from "./data";
// 好友列表
export function getWechatFriendList() {
return request("/v1/kefu/wechatFriend/list", {}, "GET");
}
// 群列表
export function getWechatChatroomList() {
return request("/v1/kefu/wechatChatroom/list", {}, "GET");
}
//群、好友聊天记录列表
export function getChatroomList() {
return request("/v1/kefu/wechatChatroom/list", {}, "GET");

View File

@@ -22,21 +22,21 @@ const CkboxPage: React.FC = () => {
setLoading(true);
chatInitAPIdata()
.then(response => {
const data = response as {
contractList: any[];
groupList: any[];
kfUserList: KfUserListData[];
newContractList: { groupName: string; contacts: any[] }[];
};
const { contractList } = data;
// const data = response as {
// contractList: any[];
// groupList: any[];
// kfUserList: KfUserListData[];
// newContractList: { groupName: string; contacts: any[] }[];
// };
// const { contractList } = data;
//找出已经在聊天的
const isChatList = contractList.filter(
v => (v?.config && v.config?.chat) || false,
);
isChatList.forEach(v => {
addChatSession(v);
});
// //找出已经在聊天的
// const isChatList = contractList.filter(
// v => (v?.config && v.config?.chat) || false,
// );
// isChatList.forEach(v => {
// addChatSession(v);
// });
// 数据加载完成后初始化WebSocket连接
initSocket();

View File

@@ -15,6 +15,8 @@ import {
getGroupList,
getAgentList,
getChatroomList,
getWechatFriendList,
getWechatChatroomList,
} from "./api";
import { useUserStore } from "@/store/module/user";
@@ -31,7 +33,7 @@ const { login2 } = useUserStore.getState();
export const chatInitAPIdata = async () => {
try {
//获取联系人列表
const contractList = await getAllContactList();
const contractList = await getWechatFriendList();
//获取联系人列表
asyncContractList(contractList);
@@ -51,12 +53,12 @@ export const chatInitAPIdata = async () => {
await asyncCountLables(countLables);
//获取消息会话列表并按lastUpdateTime排序
const filterUserSessions = contractList?.filter(
v => v?.config && v.config?.chat,
);
const filterGroupSessions = groupList?.filter(
v => v?.config && v.config?.chat,
);
// const filterUserSessions = contractList?.filter(
// v => v?.config && v.config?.chat,
// );
// const filterGroupSessions = groupList?.filter(
// v => v?.config && v.config?.chat,
// );
//排序功能
// const sortedSessions = [...filterUserSessions, ...filterGroupSessions].sort(
// (a, b) => {
@@ -81,7 +83,6 @@ export const chatInitAPIdata = async () => {
// },
// );
const sortedSessions = await getChatroomList();
console.log("sortedSessions", sortedSessions);
//会话数据同步
asyncChatSessions(sortedSessions);