feat:微信详情进度保存一下

This commit is contained in:
许永平
2025-07-05 15:44:07 +08:00
parent 0dbaa114ae
commit 5a78e0bc76
4 changed files with 881 additions and 39 deletions

View File

@@ -0,0 +1,54 @@
import React, { createContext, useContext, useState, ReactNode } from 'react';
export interface WechatAccountData {
id: string;
avatar: string;
nickname: string;
status: "normal" | "abnormal";
wechatId: string;
wechatAccount: string;
deviceName: string;
deviceId: string;
}
interface WechatAccountContextType {
currentAccount: WechatAccountData | null;
setCurrentAccount: (account: WechatAccountData) => void;
clearCurrentAccount: () => void;
}
const WechatAccountContext = createContext<WechatAccountContextType>({
currentAccount: null,
setCurrentAccount: () => {},
clearCurrentAccount: () => {},
});
export const useWechatAccount = () => useContext(WechatAccountContext);
interface WechatAccountProviderProps {
children: ReactNode;
}
export function WechatAccountProvider({ children }: WechatAccountProviderProps) {
const [currentAccount, setCurrentAccountState] = useState<WechatAccountData | null>(null);
const setCurrentAccount = (account: WechatAccountData) => {
setCurrentAccountState(account);
};
const clearCurrentAccount = () => {
setCurrentAccountState(null);
};
return (
<WechatAccountContext.Provider
value={{
currentAccount,
setCurrentAccount,
clearCurrentAccount,
}}
>
{children}
</WechatAccountContext.Provider>
);
}