import React from 'react'; import { Result, Button } from 'antd'; import { history } from 'umi'; import { IRouteLayoutConfig } from '../../types/interface.d'; function backToHome() { history.push('/'); } const Exception404 = () => ( 返回首页 } /> ); const Exception403 = () => ( 返回首页 } /> ); const WithExceptionOpChildren: React.FC<{ currentPathConfig?: IRouteLayoutConfig; children: any; noFound: React.ReactNode; unAccessible: React.ReactNode; }> = (props) => { const { children, currentPathConfig } = props; // 404 现在应该很少会发生 if (!currentPathConfig) { return props.noFound || ; } /** * 这里是没有权限的意思 */ if (currentPathConfig.unAccessible || currentPathConfig.unaccessible) { return props.unAccessible || ; } return children; }; export { Exception404, Exception403, WithExceptionOpChildren };