import { useModel, history } from "@umijs/max"
type Props = { menuType: "distributor" | "miniApp", children: any, data: { appId: string, id: string, appName: string } | null}
//切换菜单展示
const MenuChange: React.FC<Props> = (props) => {
    let { menuType, children, data } = props
    let { setInitialState, initialState } = useModel("@@initialState")
    const change = () => {
        setInitialState({ ...initialState, menuType, token: initialState?.token || "", selectApp: data })
        sessionStorage.setItem("menuType",menuType)
        sessionStorage.setItem("selectApp",JSON.stringify(data))
        history.push(`/${menuType}`);
    }
    return <span onClick={change} style={{ display: 'inline-block', width: '100%' }}>{children}</span>
}
export default MenuChange