feat(store): 添加asyncKfSelected方法用于更新选中客服
添加asyncKfSelected方法到ckchat store,用于异步更新选中的客服ID。同时移除未使用的代码和console.log
This commit is contained in:
@@ -33,9 +33,7 @@ const CkboxPage: React.FC = () => {
|
||||
kfUserList: KfUserListData[];
|
||||
newContractList: { groupName: string; contacts: any[] }[];
|
||||
};
|
||||
const { contractList, groupList, kfUserList, newContractList } = data;
|
||||
|
||||
console.log(contractList, groupList, kfUserList, newContractList);
|
||||
const { contractList } = data;
|
||||
|
||||
//找出已经在聊天的
|
||||
const isChatList = contractList.filter(
|
||||
@@ -82,7 +80,7 @@ const CkboxPage: React.FC = () => {
|
||||
|
||||
// 处理垂直侧边栏用户选择
|
||||
const handleVerticalUserSelect = (userId: string) => {
|
||||
setActiveVerticalUserId(userId);
|
||||
// setActiveVerticalUserId(userId);
|
||||
// 这里可以根据选择的用户类别筛选不同的联系人列表
|
||||
// 例如:根据userId加载不同分类的联系人
|
||||
};
|
||||
@@ -96,10 +94,7 @@ const CkboxPage: React.FC = () => {
|
||||
{/* 垂直侧边栏 */}
|
||||
|
||||
<Sider width={60} className={styles.verticalSider}>
|
||||
<VerticalUserList
|
||||
activeKfUserId={activeVerticalUserId}
|
||||
onUserSelect={handleVerticalUserSelect}
|
||||
/>
|
||||
<VerticalUserList />
|
||||
</Sider>
|
||||
|
||||
{/* 左侧联系人边栏 */}
|
||||
|
||||
@@ -74,6 +74,7 @@ export interface CkChatState {
|
||||
kfUserList: KfUserListData[];
|
||||
kfSelected: number;
|
||||
newContractList: { groupName: string; contacts: any[] }[];
|
||||
asyncKfSelected: (data: number) => void;
|
||||
getkfUserList: () => KfUserListData[];
|
||||
asyncKfUserList: (data: KfUserListData[]) => void;
|
||||
asyncContractList: (data: ContractData[]) => void;
|
||||
|
||||
@@ -8,6 +8,7 @@ import {
|
||||
KfUserListData,
|
||||
} from "./ckchat.data";
|
||||
import { ContractData, GroupData } from "@/pages/pc/ckbox/data";
|
||||
|
||||
export const useCkChatStore = createPersistStore<CkChatState>(
|
||||
set => ({
|
||||
userInfo: null,
|
||||
@@ -15,7 +16,11 @@ export const useCkChatStore = createPersistStore<CkChatState>(
|
||||
contractList: [], //联系人列表
|
||||
chatSessions: [], //聊天会话
|
||||
kfUserList: [], //客服列表
|
||||
kfSelected: 0,
|
||||
newContractList: [], //联系人分组
|
||||
asyncKfSelected: (data: number) => {
|
||||
set({ kfSelected: data });
|
||||
},
|
||||
// 异步设置会话列表
|
||||
asyncNewContractList: data => {
|
||||
set({ newContractList: data });
|
||||
@@ -194,3 +199,5 @@ export const asyncChatSessions = (data: ContractData[]) =>
|
||||
export const asyncNewContractList = (
|
||||
data: { groupName: string; contacts: any[] }[],
|
||||
) => useCkChatStore.getState().asyncNewContractList(data);
|
||||
export const asyncKfSelected = (data: number) =>
|
||||
useCkChatStore.getState().asyncKfSelected(data);
|
||||
|
||||
Reference in New Issue
Block a user