import React, { useEffect } from 'react'; import { Redirect, RouterTypes } from 'umi' import { connect } from 'dva'; import { UserModelState } from '@/models/user'; import styles from './index.css'; const unauthorizedPaths = [ '/check', '/register', ]; const Page: React.FC = ({ isLogin, children, location: { pathname }, }) => { if (pathname !== '/' && !isLogin && !unauthorizedPaths.includes(pathname)) { return } if (isLogin && unauthorizedPaths.includes(pathname)) { return ; } return ( <>{children} ); }; export default connect( ({ user }: any) => ({ ...user }), )(Page);