|
|
@ -1,4 +1,5 @@ |
|
|
import type { Settings as LayoutSettings } from '@ant-design/pro-layout'; |
|
|
import type { Settings as LayoutSettings } from '@ant-design/pro-layout'; |
|
|
|
|
|
import { SettingDrawer } from '@ant-design/pro-layout'; |
|
|
import { PageLoading } from '@ant-design/pro-layout'; |
|
|
import { PageLoading } from '@ant-design/pro-layout'; |
|
|
import type { RunTimeLayoutConfig } from 'umi'; |
|
|
import type { RunTimeLayoutConfig } from 'umi'; |
|
|
import { history, Link } from 'umi'; |
|
|
import { history, Link } from 'umi'; |
|
|
@ -21,6 +22,7 @@ export const initialStateConfig = { |
|
|
export async function getInitialState(): Promise<{ |
|
|
export async function getInitialState(): Promise<{ |
|
|
settings?: Partial<LayoutSettings>; |
|
|
settings?: Partial<LayoutSettings>; |
|
|
currentUser?: API.CurrentUser; |
|
|
currentUser?: API.CurrentUser; |
|
|
|
|
|
loading?: boolean; |
|
|
fetchUserInfo?: () => Promise<API.CurrentUser | undefined>; |
|
|
fetchUserInfo?: () => Promise<API.CurrentUser | undefined>; |
|
|
}> { |
|
|
}> { |
|
|
const fetchUserInfo = async () => { |
|
|
const fetchUserInfo = async () => { |
|
|
@ -48,7 +50,7 @@ export async function getInitialState(): Promise<{ |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// ProLayout 支持的api https://procomponents.ant.design/components/layout
|
|
|
// ProLayout 支持的api https://procomponents.ant.design/components/layout
|
|
|
export const layout: RunTimeLayoutConfig = ({ initialState }) => { |
|
|
export const layout: RunTimeLayoutConfig = ({ initialState, setInitialState }) => { |
|
|
return { |
|
|
return { |
|
|
rightContentRender: () => <RightContent />, |
|
|
rightContentRender: () => <RightContent />, |
|
|
disableContentMargin: false, |
|
|
disableContentMargin: false, |
|
|
@ -79,10 +81,26 @@ export const layout: RunTimeLayoutConfig = ({ initialState }) => { |
|
|
// 自定义 403 页面
|
|
|
// 自定义 403 页面
|
|
|
// unAccessible: <div>unAccessible</div>,
|
|
|
// unAccessible: <div>unAccessible</div>,
|
|
|
// 增加一个 loading 的状态
|
|
|
// 增加一个 loading 的状态
|
|
|
// childrenRender: (children) => {
|
|
|
childrenRender: (children, props) => { |
|
|
// if (initialState.loading) return <PageLoading />;
|
|
|
// if (initialState?.loading) return <PageLoading />;
|
|
|
// return children;
|
|
|
return ( |
|
|
// },
|
|
|
<> |
|
|
|
|
|
{children} |
|
|
|
|
|
{!props.location?.pathname?.includes('/login') && ( |
|
|
|
|
|
<SettingDrawer |
|
|
|
|
|
enableDarkTheme |
|
|
|
|
|
settings={initialState?.settings} |
|
|
|
|
|
onSettingChange={(settings) => { |
|
|
|
|
|
setInitialState((preInitialState) => ({ |
|
|
|
|
|
...preInitialState, |
|
|
|
|
|
settings, |
|
|
|
|
|
})); |
|
|
|
|
|
}} |
|
|
|
|
|
/> |
|
|
|
|
|
)} |
|
|
|
|
|
</> |
|
|
|
|
|
); |
|
|
|
|
|
}, |
|
|
...initialState?.settings, |
|
|
...initialState?.settings, |
|
|
}; |
|
|
}; |
|
|
}; |
|
|
}; |
|
|
|