更新 index.html 和 manifest.json 中的脚本文件名,替换为新的构建版本 index-ROCKxzay.js,以确保正确加载最新的资源。
This commit is contained in:
@@ -61,6 +61,7 @@ export interface CkChatState {
|
||||
clearkfUserList: () => void;
|
||||
addChatSession: (session: any) => void;
|
||||
deleteChatSession: (sessionId: number) => void;
|
||||
pinChatSessionToTop: (sessionId: number) => void;
|
||||
setUserInfo: (userInfo: CkUserInfo) => void;
|
||||
clearUserInfo: () => void;
|
||||
updateAccount: (account: Partial<CkAccount>) => void;
|
||||
|
||||
@@ -375,11 +375,11 @@ export const useCkChatStore = createPersistStore<CkChatState>(
|
||||
set(state => {
|
||||
// 检查是否已存在相同id的会话
|
||||
const exists = state.chatSessions.some(item => item.id === session.id);
|
||||
// 如果已存在则不添加,否则添加到列表中
|
||||
// 如果已存在则不添加,否则添加到列表顶部
|
||||
return {
|
||||
chatSessions: exists
|
||||
? state.chatSessions
|
||||
: [...state.chatSessions, session as ContractData | weChatGroup],
|
||||
: [session as ContractData | weChatGroup, ...state.chatSessions],
|
||||
};
|
||||
});
|
||||
},
|
||||
@@ -399,6 +399,24 @@ export const useCkChatStore = createPersistStore<CkChatState>(
|
||||
//当前选中的客户清空
|
||||
getClearCurrentContact();
|
||||
},
|
||||
// 置顶聊天会话到列表顶部
|
||||
pinChatSessionToTop: (sessionId: number) => {
|
||||
set(state => {
|
||||
const sessionIndex = state.chatSessions.findIndex(
|
||||
item => item.id === sessionId,
|
||||
);
|
||||
if (sessionIndex === -1) return state; // 会话不存在
|
||||
|
||||
const session = state.chatSessions[sessionIndex];
|
||||
const otherSessions = state.chatSessions.filter(
|
||||
item => item.id !== sessionId,
|
||||
);
|
||||
|
||||
return {
|
||||
chatSessions: [session, ...otherSessions],
|
||||
};
|
||||
});
|
||||
},
|
||||
// 设置用户信息
|
||||
setUserInfo: (userInfo: CkUserInfo) => {
|
||||
set({ userInfo, isLoggedIn: true });
|
||||
@@ -524,4 +542,6 @@ export const clearSearchKeyword = () =>
|
||||
useCkChatStore.getState().clearSearchKeyword();
|
||||
export const searchContactsAndGroups = () =>
|
||||
useCkChatStore.getState().searchContactsAndGroups();
|
||||
export const pinChatSessionToTop = (sessionId: number) =>
|
||||
useCkChatStore.getState().pinChatSessionToTop(sessionId);
|
||||
useCkChatStore.getState().getKfSelectedUser();
|
||||
|
||||
@@ -18,6 +18,7 @@ import {
|
||||
addChatSession,
|
||||
updateChatSession,
|
||||
useCkChatStore,
|
||||
pinChatSessionToTop,
|
||||
} from "@/store/module/ckchat/ckchat";
|
||||
|
||||
/**
|
||||
@@ -285,6 +286,8 @@ export const useWeChatStore = create<WeChatState>()(
|
||||
if (session) {
|
||||
session.unreadCount = Number(session.unreadCount) + 1;
|
||||
updateChatSession(session);
|
||||
// 将接收到新消息的会话置顶到列表顶部
|
||||
pinChatSessionToTop(getMessageId);
|
||||
} else {
|
||||
// 如果会话不存在,创建新会话
|
||||
if (isWechatGroup) {
|
||||
@@ -294,6 +297,7 @@ export const useWeChatStore = create<WeChatState>()(
|
||||
...group,
|
||||
unreadCount: 1,
|
||||
});
|
||||
// 新创建的会话会自动添加到列表顶部,无需额外置顶
|
||||
}
|
||||
} else {
|
||||
const [user] = await contractService.findByIds(getMessageId);
|
||||
@@ -301,6 +305,7 @@ export const useWeChatStore = create<WeChatState>()(
|
||||
...user,
|
||||
unreadCount: 1,
|
||||
});
|
||||
// 新创建的会话会自动添加到列表顶部,无需额外置顶
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user