text: import { isUrl } from '../utils/utils';
  
  const menuData = [
    {
      name: 'component',
      icon: 'home',
      path: 'component',
      children: [
        {
          name: 'Button',
          path: 'button',
        },
        {
          name: 'Checkbox',
          path: 'checkbox',
        },
        {
          name: 'CheckboxTag',
          path: 'checkboxTag',
        },
        {
          name: 'Radio',
          path: 'radio',
        },
        {
          name: 'Tag',
          path: 'tag',
        },
      ],
    },
    {
      name: '异常页',
      icon: 'warning',
      path: 'exception',
      children: [
        {
          name: '403',
          path: '403',
        },
        {
          name: '404',
          path: '404',
        },
        {
          name: '500',
          path: '500',
        },
        {
          name: '触发异常',
          path: 'trigger',
          hideInMenu: true,
        },
      ],
    },
    {
      name: '账户',
      icon: 'user',
      path: 'user',
      authority: 'guest',
      children: [
        {
          name: '登录',
          path: 'login',
        },
        {
          name: '注册',
          path: 'register',
        },
        {
          name: '注册结果',
          path: 'register-result',
        },
      ],
    },
  ];
  
  function formatter(data, parentPath = '/', parentAuthority) {
    return data.map(item => {
      let { path } = item;
      if (!isUrl(path)) {
        path = parentPath + item.path;
      }
      const result = {
        ...item,
        path,
        authority: item.authority || parentAuthority,
      };
      if (item.children) {
        result.children = formatter(item.children, `${parentPath}${item.path}/`, item.authority);
      }
      return result;
    });
  }
  
  export const getMenuData = () => formatter(menuData);
  