refactor(数据库): 重命名GroupData为wechatGroup并优化数据库初始化
重构GroupData接口为wechatGroup以更准确描述微信群组数据结构 在数据库初始化时添加调试模式清理数据功能 更新所有相关引用和数据库服务实例名称
This commit is contained in:
@@ -2,7 +2,7 @@ import { createPersistStore } from "@/store/createPersistStore";
|
||||
import { CkChatState, CkUserInfo, CkTenant } from "./ckchat.data";
|
||||
import {
|
||||
ContractData,
|
||||
GroupData,
|
||||
wechatGroup,
|
||||
CkAccount,
|
||||
KfUserListData,
|
||||
} from "@/pages/pc/ckbox/data";
|
||||
@@ -18,16 +18,11 @@ export const useCkChatStore = createPersistStore<CkChatState>(
|
||||
newContractList: [], //联系人分组
|
||||
//客服列表
|
||||
asyncKfUserList: async data => {
|
||||
console.log(data);
|
||||
|
||||
await kfUserService.createManyWithServerId(data);
|
||||
// set({ kfUserList: data });
|
||||
},
|
||||
// 获取客服列表
|
||||
getkfUserList: async () => {
|
||||
return await kfUserService.findAll();
|
||||
// const state = useCkChatStore.getState();
|
||||
// return state.kfUserList;
|
||||
},
|
||||
asyncKfSelected: (data: number) => {
|
||||
set({ kfSelected: data });
|
||||
@@ -78,7 +73,7 @@ export const useCkChatStore = createPersistStore<CkChatState>(
|
||||
return state.chatSessions;
|
||||
},
|
||||
// 添加聊天会话
|
||||
addChatSession: (session: ContractData | GroupData) => {
|
||||
addChatSession: (session: ContractData | wechatGroup) => {
|
||||
set(state => {
|
||||
// 检查是否已存在相同id的会话
|
||||
const exists = state.chatSessions.some(item => item.id === session.id);
|
||||
@@ -86,12 +81,12 @@ export const useCkChatStore = createPersistStore<CkChatState>(
|
||||
return {
|
||||
chatSessions: exists
|
||||
? state.chatSessions
|
||||
: [...state.chatSessions, session as ContractData | GroupData],
|
||||
: [...state.chatSessions, session as ContractData | wechatGroup],
|
||||
};
|
||||
});
|
||||
},
|
||||
// 更新聊天会话
|
||||
updateChatSession: (session: ContractData | GroupData) => {
|
||||
updateChatSession: (session: ContractData | wechatGroup) => {
|
||||
set(state => ({
|
||||
chatSessions: state.chatSessions.map(item =>
|
||||
item.id === session.id ? session : item,
|
||||
@@ -186,9 +181,9 @@ export const getCkAccountName = () =>
|
||||
export const getCkTenantName = () => useCkChatStore.getState().getTenantName();
|
||||
export const getChatSessions = () =>
|
||||
useCkChatStore.getState().getChatSessions();
|
||||
export const addChatSession = (session: ContractData | GroupData) =>
|
||||
export const addChatSession = (session: ContractData | wechatGroup) =>
|
||||
useCkChatStore.getState().addChatSession(session);
|
||||
export const updateChatSession = (session: ContractData | GroupData) =>
|
||||
export const updateChatSession = (session: ContractData | wechatGroup) =>
|
||||
useCkChatStore.getState().updateChatSession(session);
|
||||
export const deleteChatSession = (sessionId: string) =>
|
||||
useCkChatStore.getState().deleteChatSession(sessionId);
|
||||
|
||||
Reference in New Issue
Block a user