Files
vic-user-react/src/pages/home/_layout.tsx
2019-09-04 16:14:16 +08:00

41 lines
936 B
TypeScript

/**
* Routes:
* - ./src/pages/routes
*/
import React from 'react';
import { connect, DispatchProp } from 'dva';
import { RouterTypes, Redirect } from 'umi';
import Tab from '@/components/Tab';
import styles from './style.less';
import { HomeModelState } from './model';
const HomePage: React.FC<RouterTypes & DispatchProp & HomeModelState> = ({
dispatch,
tabItems,
selectedTab,
location: { pathname },
children,
}) => {
if (pathname === '/home') return <Redirect to="/home/estate" />
return (
<div className={styles.home}>
<section className={styles.page}>
{children}
</section>
<footer className={styles.tab}>
<Tab
items={tabItems}
selectedKey={selectedTab}
onChange={payload => dispatch({ type: 'home/changeTab', payload })}
/>
</footer>
</div>
);
}
export default connect(
({ home }: any) => ({ ...home }),
)(HomePage);