ant design pro 脚手架项目app.tsx功能配置

265 阅读1分钟
  • 二级菜单不显示图标问题
  menuItemRender: (menuItemProps, defaultDom) => {
      if (menuItemProps.isUrl || !menuItemProps.path) {
        return defaultDom;
      }
      // 支持二级菜单显示icon

      return (
        <Link to={menuItemProps.path}>
          {menuItemProps.pro_layout_parentKeys &&
            menuItemProps.pro_layout_parentKeys.length > 0 &&
            menuItemProps.icon}
          {defaultDom}
        </Link>
      );
    },
  • 去掉水印功能,注释本行
   // waterMarkProps: {
    //   content: initialState?.currentUser?.name,
    // },
  • 动态配置路由
 menu: {
      // 每当 initialState?.currentUser?.userid 发生修改时重新执行 request
      // params: initialState,
      request: async (params, defaultMenuData) => {
        // 如果是登录页面,不执行
        if (history.location.pathname !== loginPath) {
          // initialState.currentUser 中包含了所有用户信息
          // return [
          //   {
          //     path: '/product',
          //     name: '产品管理',
          //     routes: [
          //       {
          //         path: '/product/list',
          //         name: '产品列表',
          //       },
          //       {
          //         path: '/product/new',
          //         name: '新建产品',
          //       },
          //     ],
          //   },
          // ];
          return resourceList;
        }
      },
      locale: false,
    },