30 lines
1.0 KiB
TypeScript
30 lines
1.0 KiB
TypeScript
import { PageContainer } from '@ant-design/pro-layout';
|
|
import type { RunTimeLayoutConfig } from 'umi';
|
|
import { history } from 'umi';
|
|
import RightContent from '@/components/RightContent';
|
|
import RoutePath from '@/routes/routePath';
|
|
import { CACHE_TOKEN } from '@/constants/cacheKey';
|
|
|
|
// ProLayout 支持的api https://procomponents.ant.design/components/layout
|
|
export const layout: RunTimeLayoutConfig = ({ initialState }) => {
|
|
return {
|
|
rightContentRender: () => <RightContent />,
|
|
disableContentMargin: false,
|
|
onPageChange: () => {
|
|
if (!localStorage.getItem(CACHE_TOKEN)) {
|
|
history.push(RoutePath.LOGIN);
|
|
}
|
|
},
|
|
|
|
menuHeaderRender: undefined,
|
|
// 自定义 403 页面
|
|
// unAccessible: <div>unAccessible</div>,
|
|
// 增加一个 loading 的状态
|
|
childrenRender: (children) => {
|
|
const pathname = location.hash.replace('#', '');
|
|
return pathname === RoutePath.LOGIN ? children : <PageContainer>{children}</PageContainer>;
|
|
},
|
|
...initialState?.settings,
|
|
};
|
|
};
|