From 711159aa2b61d05538a3b45f5074d1a658369a8a 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: Thu, 4 Sep 2025 16:33:03 +0800 Subject: [PATCH] =?UTF-8?q?FEAT=20=3D>=20=E6=9C=AC=E6=AC=A1=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=E9=A1=B9=E7=9B=AE=E4=B8=BA=EF=BC=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Cunkebao/src/pages/pc/ckbox/api.ts | 12 ++++++++++++ Cunkebao/src/store/module/weChat/weChat.ts | 11 ++++++----- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/Cunkebao/src/pages/pc/ckbox/api.ts b/Cunkebao/src/pages/pc/ckbox/api.ts index daa8a79a..e8927829 100644 --- a/Cunkebao/src/pages/pc/ckbox/api.ts +++ b/Cunkebao/src/pages/pc/ckbox/api.ts @@ -39,6 +39,18 @@ export function getChatMessages(params: { }) { return request("/api/FriendMessage/SearchMessage", params, "GET"); } +export function getChatroomMessages(params: { + wechatAccountId: number; + wechatFriendId?: number; + wechatChatroomId?: number; + From: number; + To: number; + Count: number; + olderData: boolean; +}) { + return request("/api/ChatroomMessage/SearchMessage", params, "GET"); +} + //获取群列表 export function getGroupList(params: { prevId: number; count: number }) { return request( diff --git a/Cunkebao/src/store/module/weChat/weChat.ts b/Cunkebao/src/store/module/weChat/weChat.ts index 6025102c..22afe3b8 100644 --- a/Cunkebao/src/store/module/weChat/weChat.ts +++ b/Cunkebao/src/store/module/weChat/weChat.ts @@ -1,6 +1,6 @@ import { create } from "zustand"; import { persist } from "zustand/middleware"; -import { getChatMessages } from "@/pages/pc/ckbox/api"; +import { getChatMessages, getChatroomMessages } from "@/pages/pc/ckbox/api"; import { WeChatState } from "./weChat.data"; import { clearUnreadCount, updateConfig } from "@/pages/pc/ckbox/api"; import { ContractData, weChatGroup } from "@/pages/pc/ckbox/data"; @@ -49,18 +49,19 @@ export const useWeChatStore = create()( wechatAccountId: contact.wechatAccountId, From: 1, To: 4704624000000, - Count: 10, + Count: 5, olderData: true, }; if ("chatroomId" in contact && contact.chatroomId) { params.wechatChatroomId = contact.id; + const messages = await getChatroomMessages(params); + set({ currentMessages: messages || [] }); } else { params.wechatFriendId = contact.id; + const messages = await getChatMessages(params); + set({ currentMessages: messages || [] }); } - - const messages = await getChatMessages(params); - set({ currentMessages: messages || [] }); } catch (error) { console.error("获取聊天消息失败:", error); } finally {