import React from 'react'; import PropTypes from 'prop-types'; import { Layout, Icon } from 'antd'; import DocumentTitle from 'react-document-title'; import { connect } from 'dva'; import { Route, Redirect, Switch } from 'dva/router'; import { ContainerQuery } from 'react-container-query'; import classNames from 'classnames'; import GlobalHeader from '../components/GlobalHeader'; import GlobalFooter from '../components/GlobalFooter'; import SiderMenu from '../components/SiderMenu'; import NotFound from '../routes/Exception/404'; const { Content } = Layout; const query = { 'screen-xs': { maxWidth: 575, }, 'screen-sm': { minWidth: 576, maxWidth: 767, }, 'screen-md': { minWidth: 768, maxWidth: 991, }, 'screen-lg': { minWidth: 992, maxWidth: 1199, }, 'screen-xl': { minWidth: 1200, }, }; class BasicLayout extends React.PureComponent { static childContextTypes = { location: PropTypes.object, breadcrumbNameMap: PropTypes.object, } getChildContext() { const { location, navData, getRouteData } = this.props; const routeData = getRouteData('BasicLayout'); const firstMenuData = navData.reduce((arr, current) => arr.concat(current.children), []); const menuData = this.getMenuData(firstMenuData, ''); const breadcrumbNameMap = {}; routeData.concat(menuData).forEach((item) => { breadcrumbNameMap[item.path] = { name: item.name, component: item.component, }; }); return { location, breadcrumbNameMap }; } getPageTitle() { const { location, getRouteData } = this.props; const { pathname } = location; let title = 'Ant Design Pro'; getRouteData('BasicLayout').forEach((item) => { if (item.path === pathname) { title = `${item.name} - Ant Design Pro`; } }); return title; } getMenuData = (data, parentPath) => { let arr = []; data.forEach((item) => { if (item.children) { arr.push({ path: `${parentPath}/${item.path}`, name: item.name }); arr = arr.concat(this.getMenuData(item.children, `${parentPath}/${item.path}`)); } }); return arr; } render() { const { currentUser, collapsed, fetchingNotices, notices, getRouteData, navData, location, dispatch, } = this.props; const layout = (
{ getRouteData('BasicLayout').map(item => ( ) ) }
Copyright 2017 蚂蚁金服体验技术部出品 } />
); return ( {params =>
{layout}
}
); } } export default connect(state => ({ currentUser: state.user.currentUser, collapsed: state.global.collapsed, fetchingNotices: state.global.fetchingNotices, notices: state.global.notices, }))(BasicLayout);