umi#RunTimeLayoutConfig TypeScript Examples

The following examples show how to use umi#RunTimeLayoutConfig. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: app.tsx    From ant-design-pro-V5-multitab with MIT License 5 votes vote down vote up
layout: RunTimeLayoutConfig = ({ initialState, setInitialState }) => {
    return {
        rightContentRender: () => <RightContent />,
        disableContentMargin: true,
        footerRender: () => <Footer />,
        headerRender: () => <HeaderRender />,
        headerHeight: 93,
        onPageChange: () => {
            const { location } = history;
            // 如果没有登录,重定向到 login
            if (!initialState?.currentUser && location.pathname !== '/user/login') {
                history.push('/user/login');
            }
        },
        onCollapse: (collapsed) => {
            setInitialState({ ...initialState, collapsed })
        },
        // menuHeaderRender: (logo, title, props) => {
        //   console.log(logo);
        //   console.log(title);
        //   console.log(props);
        // },
        // patchMenus: (menuData: Array<any>) => {
        //     let menuArr: Array<any> = [];
        //     menuData.forEach((item) => {
        //         if (item.path === "/") {
        //             menuArr = [...menuArr, ...item.children]
        //         } else {
        //             menuArr.push(item)
        //         }
        //     })
        //     return menuArr
        // },
        // childrenRender: (children) => {
        //     return (
        //         <AliveScope>
        //             {children}
        //         </AliveScope>
        //     )
        // },
        // 自定义 403 页面
        // unAccessible: <div>unAccessible</div>,
        ...initialState?.settings,
    };
}
Example #2
Source File: app.tsx    From anew-server with MIT License 5 votes vote down vote up
layout: RunTimeLayoutConfig = ({ initialState }) => {
  return {
    rightContentRender: () => <RightContent />,
    disableContentMargin: false,
    waterMarkProps: {
      content: initialState?.currentUser?.name,
    },
    footerRender: () => <Footer />,
    onPageChange: () => {
      const { location } = history;
      // 如果没有登录,重定向到 login
      if (!initialState?.currentUser && location.pathname !== loginPath) {
        history.push(loginPath);
      }
    },
    menu: {
      // 每当 initialState?.currentUser?.userid 发生修改时重新执行 request
      params: {
        userId: initialState?.currentUser?.id,
      },
      request: async (params, defaultMenuData) => {
        if (!params.userId) return []
        const menuData = await (await GetMenuTree()).data;
        return menuData;
      },
    },
    // links: isDev
    //   ? [
    //     <Link to="/umi/plugin/openapi" target="_blank">
    //       <LinkOutlined />
    //       <span>OpenAPI 文档</span>
    //     </Link>,
    //     <Link to="/~docs">
    //       <BookOutlined />
    //       <span>业务组件文档</span>
    //     </Link>,
    //   ]
    //   : [],
    menuHeaderRender: undefined,
    // 自定义 403 页面
    // unAccessible: <div>unAccessible</div>,
    ...initialState?.settings,
  };
}