Reinit project

This commit is contained in:
Limo Saplf
2019-08-31 20:44:15 +08:00
commit b51ae824c7
115 changed files with 20955 additions and 0 deletions

31
src/pages/routes.tsx Normal file
View File

@@ -0,0 +1,31 @@
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<RouterTypes & UserModelState> = ({
isLogin,
children,
location: { pathname },
}) => {
if (pathname !== '/' && !isLogin && !unauthorizedPaths.includes(pathname)) {
return <Redirect to="/check" />
}
if (isLogin && unauthorizedPaths.includes(pathname)) {
return <Redirect to="/home" />;
}
return (
<>{children}</>
);
};
export default connect(
({ user }: any) => ({ ...user }),
)(Page);