feat(客服聊天): 添加获取当前选中客服用户的功能

在CkChatState接口中添加kfSelectedUser方法用于获取当前选中的客服用户信息,并在聊天窗口组件中显示该信息
This commit is contained in:
超级老白兔
2025-08-29 15:40:46 +08:00
parent 8e177534f4
commit db4bc8651d
3 changed files with 8 additions and 0 deletions

View File

@@ -50,6 +50,7 @@ import { clearUnreadCount, getMessages } from "@/pages/pc/ckbox/api";
import styles from "./ChatWindow.module.scss";
import { useWebSocketStore, WebSocketMessage } from "@/store/module/websocket";
import { formatWechatTime } from "@/utils/common";
import { useCkChatStore } from "@/store/module/ckchat";
const { Header, Content, Footer, Sider } = Layout;
const { TextArea } = Input;
@@ -78,6 +79,7 @@ const ChatWindow: React.FC<ChatWindowProps> = ({
const [remarkValue, setRemarkValue] = useState(contract.conRemark || "");
const messagesEndRef = useRef<HTMLDivElement>(null);
const kfSelectedUser = useCkChatStore(state => state.kfSelectedUser());
useEffect(() => {
clearUnreadCount([contract.id]).then(() => {
setLoading(true);
@@ -1063,6 +1065,7 @@ const ChatWindow: React.FC<ChatWindowProps> = ({
</Tooltip>
<div className={styles.profileRemark}>
{JSON.stringify(kfSelectedUser)}
{isEditingRemark ? (
<div
style={{

View File

@@ -31,6 +31,7 @@ export interface CkChatState {
chatSessions: any[];
kfUserList: KfUserListData[];
kfSelected: number;
kfSelectedUser: () => KfUserListData | undefined;
newContractList: { groupName: string; contacts: any[] }[];
asyncKfSelected: (data: number) => void;
getkfUserList: () => KfUserListData[];

View File

@@ -16,6 +16,10 @@ export const useCkChatStore = createPersistStore<CkChatState>(
kfUserList: [], //客服列表
kfSelected: 0,
newContractList: [], //联系人分组
kfSelectedUser: () => {
const state = useCkChatStore.getState();
return state.kfUserList.find(item => item.id === state.kfSelected);
},
asyncKfSelected: (data: number) => {
set({ kfSelected: data });
},