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({ currentAccount: null, setCurrentAccount: () => {}, clearCurrentAccount: () => {}, }); export const useWechatAccount = () => useContext(WechatAccountContext); interface WechatAccountProviderProps { children: ReactNode; } export function WechatAccountProvider({ children }: WechatAccountProviderProps) { const [currentAccount, setCurrentAccountState] = useState(null); const setCurrentAccount = (account: WechatAccountData) => { setCurrentAccountState(account); }; const clearCurrentAccount = () => { setCurrentAccountState(null); }; return ( {children} ); }