fix(ckchat): 将deleteChatSession参数类型从string改为number

修改deleteChatSession方法的参数类型以匹配实际使用场景,同时在相关组件中直接使用store中的方法而非直接导入,保持
This commit is contained in:
超级老白兔
2025-09-10 17:55:17 +08:00
parent 95303d2960
commit 8507b640b2
4 changed files with 9 additions and 21 deletions

View File

@@ -7,7 +7,7 @@ import {
WechatFriendRebackAllot,
} from "@/pages/pc/ckbox/weChat/api";
import { useCurrentContact } from "@/store/module/weChat/weChat";
import { deleteChatSession } from "@/store/module/ckchat/ckchat";
import { useCkChatStore } from "@/store/module/ckchat/ckchat";
import { contractService, weChatGroupService } from "@/utils/db";
const { TextArea } = Input;
const { Option } = Select;
@@ -39,6 +39,7 @@ const ToContract: React.FC<ToContractProps> = ({
const [customerServiceList, setCustomerServiceList] = useState<DepartItem[]>(
[],
);
const deleteChatSession = useCkChatStore(state => state.deleteChatSession);
// 打开弹窗
const openModal = () => {
setVisible(true);
@@ -89,12 +90,12 @@ const ToContract: React.FC<ToContractProps> = ({
message.success("转接成功");
try {
// 删除聊天会话
deleteChatSession(currentContact.id.toString());
deleteChatSession(currentContact.id);
// 删除本地数据库记录
if ("chatroomId" in currentContact) {
await weChatGroupService.delete(currentContact.id);
} else {
await contractService.delete(currentContact.id.toString());
await contractService.delete(currentContact.id);
}
} catch (deleteError) {
console.error("删除本地数据失败:", deleteError);
@@ -129,7 +130,7 @@ const ToContract: React.FC<ToContractProps> = ({
message.success("转回成功");
try {
// 删除聊天会话
deleteChatSession(currentContact.id.toString());
deleteChatSession(currentContact.id);
// 删除本地数据库记录
if ("chatroomId" in currentContact) {
await weChatGroupService.delete(currentContact.id);

View File

@@ -1,12 +1,9 @@
import React, { useState } from "react";
import { Layout, Input, Button, Tooltip, Modal } from "antd";
import { Layout, Input, Button, Modal } from "antd";
import {
ShareAltOutlined,
SendOutlined,
AudioOutlined,
FolderOutlined,
PictureOutlined,
MessageOutlined,
} from "@ant-design/icons";
import { ContractData, weChatGroup } from "@/pages/pc/ckbox/data";
import { useWebSocketStore } from "@/store/module/websocket/websocket";
@@ -176,17 +173,7 @@ const MessageEnter: React.FC<MessageEnterProps> = ({ contract }) => {
/>
</div>
<div className={styles.rightTool}>
<ToContract
className={styles.rightToolItem}
onTransfer={data => {
console.log("转接数据:", data);
// 这里可以添加实际的转接逻辑
}}
onReturn={() => {
console.log("执行一键转回操作");
// 这里可以添加实际的转回逻辑
}}
/>
<ToContract className={styles.rightToolItem} />
<ChatRecord
className={styles.rightToolItem}
onSearch={data => {

View File

@@ -60,7 +60,7 @@ export interface CkChatState {
updateCtrlUser: (user: KfUserListData) => void;
clearkfUserList: () => void;
addChatSession: (session: any) => void;
deleteChatSession: (sessionId: string) => void;
deleteChatSession: (sessionId: number) => void;
setUserInfo: (userInfo: CkUserInfo) => void;
clearUserInfo: () => void;
updateAccount: (account: Partial<CkAccount>) => void;

View File

@@ -389,7 +389,7 @@ export const useCkChatStore = createPersistStore<CkChatState>(
}));
},
// 删除聊天会话
deleteChatSession: (sessionId: string) => {
deleteChatSession: (sessionId: number) => {
set(state => ({
chatSessions: state.chatSessions.filter(item => item.id !== sessionId),
}));