packages/midway-init/boilerplate/midway-ts-ant-design-pro-boilerplate/boilerplate/client/src/models/menu.js
function formatter(data, parentAuthority, parentName) {
  if (!data) {
    return undefined;
  }
  return data
    .map(item => {
      if (!item.name || !item.path) {
        return null;
      }

      let locale = 'menu';
      if (parentName && parentName !== '/') {
        locale = `${parentName}.${item.name}`;
      } else {
        locale = `menu.${item.name}`;
      }
      const result = {
        ...item,
        title:locale
      };
      if (item.routes) {
        const children = formatter(item.routes, item.authority, locale);
        // Reduce memory usage
        result.children = children;
      }
      delete result.routes;
      return result;
    })
    .filter(item => item);
}
function formatter(data, parentAuthority, parentName) {
  if (!data) {
    return undefined;
  }
  return data
    .map(item => {
      if (!item.name || !item.path) {
        return null;
      }

      let locale = 'menu';
      if (parentName && parentName !== '/') {
        locale = `${parentName}.${item.name}`;
      } else {
        locale = `menu.${item.name}`;
      }
      const result = {
        ...item,
        title:locale
      };
      if (item.routes) {
        const children = formatter(item.routes, item.authority, locale);
        // Reduce memory usage
        result.children = children;
      }
      delete result.routes;
      return result;
    })
    .filter(item => item);
}
function formatter ( data , parentAuthority , parentName ) { if ( ! data ) { return undefined ; } return data . map ( item => { if ( ! item . name || ! item . path ) { return null ; } let locale = 'menu' ; if ( parentName && parentName !== '/' ) { locale = ` ${ parentName } ${ item . name } ` ; } else { locale = ` ${ item . name } ` ; } const result = { ... item , title : locale } ; if ( item . routes ) { const children = formatter ( item . routes , item . authority , locale ) ; // Reduce memory usage result . children = children ; } delete result . routes ; return result ; } ) . filter ( item => item ) ; }
Conversion router to menu.
Conversion router to menu .