import { createContext, useContext } from 'react' export type GlobalContext = { globalState: InitialStateType dispatch: (state: InitialStateType) => void } // 初始化状态值 export type InitialStateType = { userInfo?: Record accessInfo?: string[] routeAccess?: Record [propKey: string]: any } export const initGlobalState = { settings: {} } const context = createContext({ globalState: initGlobalState, dispatch: () => {} }) export const { Provider } = context export function useGlobal() { return useContext(context) }