更新TypeScript配置以支持新的模块路径别名,重命名获取客服列表的API函数,替换相关组件,移除不再使用的垂直用户列表组件及其样式,提升代码结构和可读性。

This commit is contained in:
2025-10-23 12:35:30 +08:00
parent ef45bedf83
commit 81f225d9cb
15 changed files with 292 additions and 87 deletions

View File

@@ -0,0 +1,41 @@
export interface Customer {
id: number;
tenantId: number;
wechatId: string;
nickname: string;
alias: string;
avatar: string;
gender: number;
region: string;
signature: string;
bindQQ: string;
bindEmail: string;
bindMobile: string;
createTime: string;
currentDeviceId: number;
isDeleted: boolean;
deleteTime: string;
groupId: number;
memo: string;
wechatVersion: string;
labels: string[];
lastUpdateTime: string;
isOnline?: boolean;
momentsMax: number;
momentsNum: number;
[key: string]: any;
}
//Store State
export interface CustomerState {
//客服列表
customerList: Customer[];
//当前选中的客服
currentCustomer: Customer | null;
//更新客服列表
updateCustomerList: (customerList: Customer[]) => void;
//更新客服状态
updateCustomerStatus: (customerId: number, status: string) => void;
//更新当前选中的客服
updateCurrentCustomer: (customer: Customer) => void;
}

View File

@@ -0,0 +1,56 @@
import { create } from "zustand";
import { persist } from "zustand/middleware";
import { Customer, CustomerState } from "./customer.data";
export const useCustomerStore = create<CustomerState>()(
persist(
(set, get) => ({
customerList: [], //客服列表
currentCustomer: null, //当前选中的客服
updateCustomerList: (customerList: Customer[]) => set({ customerList }), //更新客服列表
updateCurrentCustomer: (customer: Customer) =>
set({ currentCustomer: customer }), //更新当前选中的客服
updateCustomerStatus: (customerId: number, status: string) =>
set({
customerList: get().customerList.map(customer =>
customer.id === customerId ? { ...customer, status } : customer,
),
}), //更新客服状态
}),
{
name: "customer-storage",
partialize: state => ({
customerList: [],
currentCustomer: null,
}),
},
),
);
/**
* 更新当前选中的客服
* @param customer 客服
* @returns void
*/
export const updateCurrentCustomer = (customer: Customer) =>
useCustomerStore.getState().updateCurrentCustomer(customer);
/**
* 更新客服列表
* @param customerList 客服列表
* @returns void
*/
export const updateCustomerList = (customerList: Customer[]) =>
useCustomerStore.getState().updateCustomerList(customerList);
/**
* 获取当前选中的客服
* @returns Customer | null
*/
export const getCurrentCustomer = () =>
useCustomerStore.getState().currentCustomer;
/**
* 更新客服状态
* @param customerId 客服ID
* @param status 状态
* @returns void
*/
export const updateCustomerStatus = (customerId: number, status: string) =>
useCustomerStore.getState().updateCustomerStatus(customerId, status);