import React, { useEffect, useMemo, useRef } from 'react'; import { Link } from 'umi'; import { Result, Button } from 'antd'; import Authorized from '@/utils/Authorized'; import { getMatchMenu } from '@umijs/route-utils'; import Promenu from '../components/Promenu'; const noMatch = ( Go Login } /> ); const menuDataRender = (menuList: MenuDataItem[]): MenuDataItem[] => menuList.map((item) => { const localItem = { ...item, children: item.children ? menuDataRender(item.children) : undefined, }; return Authorized.check(item.authority, localItem, null) as MenuDataItem; }); const CosMenuLayout: React.FC = (props) => { const { dispatch, children, location = { pathname: '/', }, } = props; const menuDataRef = useRef([]); // useEffect(() => { // if (dispatch) { // dispatch({ // type: 'user/fetchCurrent', // }); // } // }, []); const authorized = useMemo( () => getMatchMenu(location.pathname || '/', menuDataRef.current).pop() || { authority: undefined, }, [location.pathname], ); return (
{children}
); }; export default CosMenuLayout;