import React, { ReactElement } from 'react'; import classNames from 'classnames'; import { Iconfont } from '../Iconfont/Iconfont'; import { PageTitle } from '../PageLayout/PageTitle'; import { PageContent } from '../PageLayout/PageContent'; import { PageControlLeft } from './PageControlLeft'; import { PageControlRight } from './PageControlRight'; const stylePrefix = 'jad-page-layout'; export class PageLayout extends React.Component<{ ifBackShow?: boolean, isHeaderHide?: boolean }> { public back = () => { history.back(); }; public render() { const { children, ifBackShow,isHeaderHide } = this.props; const title = React.Children.toArray(children).find( (e: ReactElement) => { return e.type === PageTitle; } ); const content = React.Children.toArray(children).find( (e: ReactElement) => { return e.type === PageContent; } ); const controlLeft = React.Children.toArray(children).find( (e: ReactElement) => { return e.type === PageControlLeft; } ); const controlRight = React.Children.toArray(children).find( (e: ReactElement) => { return e.type === PageControlRight; } ); const backBtn = ( 返回
); const pageControl = controlLeft || controlRight ? (
{controlLeft}
{controlRight}
) : ( '' ); const pageHeader = isHeaderHide? "" :(
{ifBackShow && backBtn} {title}
) return (
{pageHeader}
{pageControl}
{content}
); } }