更新消息列表组件,新增当前客户状态管理,优化消息筛选逻辑以提升用户体验和代码可读性。

This commit is contained in:
超级老白兔
2025-10-23 17:21:25 +08:00
parent 5c86c2fbf2
commit 7056e00fcc

View File

@@ -10,6 +10,7 @@ import {
import { useWeChatStore } from "@/store/module/weChat/weChat";
import { useCkChatStore } from "@/store/module/ckchat/ckchat";
import { useWebSocketStore } from "@/store/module/websocket/websocket";
import { useCustomerStore } from "@/store/module/weChat/customer";
import { updateConfig } from "@/pages/pc/ckbox/api";
import { getMessageList } from "./api";
import { dataProcessing } from "./api";
@@ -23,8 +24,8 @@ interface MessageListProps {}
const MessageList: React.FC<MessageListProps> = () => {
const { setCurrentContact, currentContract } = useWeChatStore();
const kfSelected = useCkChatStore(state => state.kfSelected);
const searchKeyword = useCkChatStore(state => state.searchKeyword);
const { currentCustomer } = useCustomerStore();
const { sendCommand } = useWebSocketStore();
const { user } = useUserStore();
const currentUserId = user?.id || 0;
@@ -392,9 +393,9 @@ const MessageList: React.FC<MessageListProps> = () => {
useEffect(() => {
let filtered = [...sessions];
// 根据客服筛选
if (kfSelected !== 0) {
filtered = filtered.filter(v => v.wechatAccountId === kfSelected);
// 根据当前选中的客服筛选
if (currentCustomer && currentCustomer.id !== 0) {
filtered = filtered.filter(v => v.wechatAccountId === currentCustomer.id);
}
// 根据搜索关键词进行模糊匹配
@@ -408,7 +409,7 @@ const MessageList: React.FC<MessageListProps> = () => {
}
setFilteredSessions(filtered);
}, [sessions, kfSelected, searchKeyword]);
}, [sessions, currentCustomer, searchKeyword]);
// ==================== WebSocket消息处理 ====================