From ad60e684fc0a8af2e9bfa117586af478425be8fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B6=85=E7=BA=A7=E8=80=81=E7=99=BD=E5=85=94?= Date: Wed, 10 Sep 2025 17:27:59 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E6=B6=88=E6=81=AF=E5=88=97=E8=A1=A8):=20?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=90=9C=E7=B4=A2=E5=8A=9F=E8=83=BD=E5=B9=B6?= =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=AE=A2=E6=9C=8D=E7=AD=9B=E9=80=89=E9=80=BB?= =?UTF-8?q?=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 添加对消息列表的搜索功能,支持根据昵称和备注进行模糊匹配 优化客服筛选逻辑,将筛选和搜索功能合并处理 在转接和转回操作后增加删除聊天会话和本地数据的逻辑 --- .../components/toContract/index.tsx | 26 +++++++++++++++++ .../SidebarMenu/MessageList/index.tsx | 28 +++++++++++++------ 2 files changed, 46 insertions(+), 8 deletions(-) diff --git a/Cunkebao/src/pages/pc/ckbox/weChat/components/ChatWindow/components/MessageEnter/components/toContract/index.tsx b/Cunkebao/src/pages/pc/ckbox/weChat/components/ChatWindow/components/MessageEnter/components/toContract/index.tsx index 96e95ceb..8fd4c404 100644 --- a/Cunkebao/src/pages/pc/ckbox/weChat/components/ChatWindow/components/MessageEnter/components/toContract/index.tsx +++ b/Cunkebao/src/pages/pc/ckbox/weChat/components/ChatWindow/components/MessageEnter/components/toContract/index.tsx @@ -7,6 +7,8 @@ import { WechatFriendRebackAllot, } from "@/pages/pc/ckbox/weChat/api"; import { useCurrentContact } from "@/store/module/weChat/weChat"; +import { deleteChatSession } from "@/store/module/ckchat/ckchat"; +import { contractService, weChatGroupService } from "@/utils/db"; const { TextArea } = Input; const { Option } = Select; @@ -85,6 +87,18 @@ const ToContract: React.FC = ({ } message.success("转接成功"); + try { + // 删除聊天会话 + deleteChatSession(currentContact.id.toString()); + // 删除本地数据库记录 + if ("chatroomId" in currentContact) { + await weChatGroupService.delete(currentContact.id); + } else { + await contractService.delete(currentContact.id.toString()); + } + } catch (deleteError) { + console.error("删除本地数据失败:", deleteError); + } closeModal(); } catch (error) { console.error("转接失败:", error); @@ -113,6 +127,18 @@ const ToContract: React.FC = ({ } message.success("转回成功"); + try { + // 删除聊天会话 + deleteChatSession(currentContact.id.toString()); + // 删除本地数据库记录 + if ("chatroomId" in currentContact) { + await weChatGroupService.delete(currentContact.id); + } else { + await contractService.delete(currentContact.id); + } + } catch (deleteError) { + console.error("删除本地数据失败:", deleteError); + } closeModal(); } catch (error) { console.error("转回失败:", error); diff --git a/Cunkebao/src/pages/pc/ckbox/weChat/components/SidebarMenu/MessageList/index.tsx b/Cunkebao/src/pages/pc/ckbox/weChat/components/SidebarMenu/MessageList/index.tsx index f954caaa..820571cc 100644 --- a/Cunkebao/src/pages/pc/ckbox/weChat/components/SidebarMenu/MessageList/index.tsx +++ b/Cunkebao/src/pages/pc/ckbox/weChat/components/SidebarMenu/MessageList/index.tsx @@ -19,17 +19,29 @@ const MessageList: React.FC = () => { const [chatSessions, setChatSessions] = useState< (ContractData | weChatGroup)[] >([]); - + const searchKeyword = useCkChatStore(state => state.searchKeyword); useEffect(() => { - if (kfSelected == 0) { - setChatSessions(getChatSessions); - } else { - const newChatSessions = getChatSessions.filter( - v => v.wechatAccountId === kfSelected && kfSelected != 0, + let filteredSessions = getChatSessions; + + // 根据客服筛选 + if (kfSelected !== 0) { + filteredSessions = filteredSessions.filter( + v => v.wechatAccountId === kfSelected, ); - setChatSessions(newChatSessions); } - }, [getChatSessions, kfSelected]); + + // 根据搜索关键词进行模糊匹配 + if (searchKeyword.trim()) { + const keyword = searchKeyword.toLowerCase(); + filteredSessions = filteredSessions.filter(v => { + const nickname = (v.nickname || "").toLowerCase(); + const conRemark = (v.conRemark || "").toLowerCase(); + return nickname.includes(keyword) || conRemark.includes(keyword); + }); + } + + setChatSessions(filteredSessions); + }, [getChatSessions, kfSelected, searchKeyword]); return (