
const routes = [

  /**********************************
   *  Tab 页面
   *********************************/
  {
    name: '登录',
    page: 'pages/login/index',
    pkg: 'main',
    isTab: true,
    type: 'main',
    shortcut: {
      chat: false,
      consultant: true,
    },
    // auth: ['phone', 'avatar']
  },
]

/**
 * 获取 app pages 列表
 */
function getPages () {
  const grp = routes.reduce((g, r) => {
    const { pkg, page } = r
    const pg = g[pkg] || []

    return Object.assign(g, {
      [`${pkg}`]: pg.concat(page),
    })
  }, {});

  const pages = grp.main;
  const subPackages = Object.keys(grp).filter(x => x !== 'main').reduce(((pkg, key) => {
    return pkg.concat({
      root: key,
      pages: grp[key],
    })
  }), [])


  return {
    pages,
    subPackages,
  }
}

// eslint-disable-next-line import/no-commonjs
module.exports = {
  routes,
  getPages,
};