feat(消息输入与记录): 增强引用消息功能与状态管理
在消息输入组件中添加引用消息的逻辑,确保引用内容能够正确显示。同时,在消息记录组件中实现引用功能的处理,优化了状态管理,提升了用户体验。
This commit is contained in:
@@ -10,6 +10,8 @@ import {
|
||||
* 包含聊天消息、联系人管理、朋友圈等功能的状态和方法
|
||||
*/
|
||||
export interface WeChatState {
|
||||
quoteMessageContent: string;
|
||||
updateQuoteMessageContent: (value: string) => void;
|
||||
// ==================== Transmit Module =========Start===========
|
||||
/** 选中的聊天记录列表 */
|
||||
selectedChatRecords: ChatRecord[];
|
||||
|
||||
@@ -27,6 +27,10 @@ import {
|
||||
export const useWeChatStore = create<WeChatState>()(
|
||||
persist(
|
||||
(set, get) => ({
|
||||
quoteMessageContent: "",
|
||||
updateQuoteMessageContent: (message: string) => {
|
||||
set({ quoteMessageContent: message });
|
||||
},
|
||||
// ==================== Transmit Module =========Start===========
|
||||
/** 选中的聊天记录列表 */
|
||||
selectedChatRecords: [],
|
||||
@@ -61,13 +65,17 @@ export const useWeChatStore = create<WeChatState>()(
|
||||
// ==================== 聊天消息管理方法 ====================
|
||||
/** 添加新消息到当前聊天 */
|
||||
addMessage: message => {
|
||||
const { wechatAccountId, wechatChatroomId, wechatFriendId } = message;
|
||||
const { wechatChatroomId, wechatFriendId } = message;
|
||||
const currentContract = get().currentContract;
|
||||
if (currentContract) {
|
||||
console.log(
|
||||
currentContract.id === wechatFriendId ||
|
||||
currentContract.id === wechatChatroomId,
|
||||
);
|
||||
|
||||
if (
|
||||
currentContract.wechatAccountId === wechatAccountId &&
|
||||
(currentContract.id === wechatFriendId ||
|
||||
currentContract.id === wechatChatroomId)
|
||||
currentContract.id === wechatFriendId ||
|
||||
currentContract.id === wechatChatroomId
|
||||
) {
|
||||
set(state => ({
|
||||
currentMessages: [...state.currentMessages, message],
|
||||
|
||||
@@ -38,7 +38,7 @@ const messageHandlers: Record<string, MessageHandler> = {
|
||||
// 发送消息响应
|
||||
CmdSendMessageResp: message => {
|
||||
console.log("发送消息响应", message);
|
||||
// addMessage(message.friendMessage || message.chatroomMessage);
|
||||
addMessage(message.friendMessage || message.chatroomMessage);
|
||||
// 在这里添加具体的处理逻辑
|
||||
},
|
||||
CmdSendMessageResult: message => {
|
||||
|
||||
Reference in New Issue
Block a user