Restart remote request menu after antd Pro V5 login


Because routing existsinitialStatethisHooksIn, as follows:

const { initialState, setInitialState } = useModel('@@initialState');

Therefore, you only need to use this code in the login logic:

//Write your own remote request interface
import { R_Menu } from '@/services/builder';
//Import system default menu
import SystemRoutes from '@/../config/routes';
//Rewrite the logic of the login page
const fetchUserInfo = async () => {
  const userInfo = await initialState?.fetchUserInfo?.();
  //Here is the logic after successfully returning user information
  if (userInfo) {
    //Call the request menu written by yourself
    const menu = await R_Menu();
    //Merge System Routing & service menu
    const freshMenu = SystemRoutes.concat(menu);
    //Overwrite the current route of the system
      menuData: freshMenu,
      currentUser: userInfo,