function load(component) {
  return resolve => require([`views/${component}`], resolve);
}

const routes = [
  { path: '/', redirect: { path: '/home' } },
  { path: '/login', name: 'Login', component: load('auth/login'), meta: { title: '登录' } },
  {
    path: '/layout',
    name: 'Layout',
    component: load('layout/index'),
    meta: { auth: true },
    children: [
      { path: '/home', name: 'Home', component: load('home/index'), meta: { title: '首页' } },
      { path: '/permissions', name: 'Permissions', component: load('system/permissions/index'), meta: { title: '权限管理' } },
      { path: '/roles', name: 'Roles', component: load('user/roles/index'), meta: { title: '角色管理' } },
      { path: '/logs', name: 'Logs', component: load('system/logs/index'), meta: { title: '日志管理' } },
      { path: '/accounts', name: 'Accounts', component: load('user/accounts/index'), meta: { title: '账号管理' } },
      { path: '/iframe', name: 'Iframe', component: load('iframe/index'), meta: { title: 'iframe' } },
      { path: '/companies', name: 'Companies', component: load('virtual/companies/index'), meta: { title: '企业管理' } },
      { path: '/company/accounts', name: 'CompanyAccounts', component: load('virtual/company_accounts/index'), meta: { title: '账号管理' } },
      { path: '/packages/:type', name: 'Packages', component: load('virtual/packages/index'), meta: { title: '套餐管理' } },
      { path: '/products/:type', name: 'Products', component: load('virtual/products/index'), meta: { title: '定价管理' } },
      { path: '/properties', name: 'Properties', component: load('virtual/properties/index'), meta: { title: '属性管理' } },
      { path: '/cards', name: 'Cards', component: load('virtual/cards/index'), meta: { title: '客户列表' } },
      { path: '/orders/:type', name: 'Orders', component: load('virtual/orders/index'), meta: { title: '订单列表' } },
      { path: '/exports', name: 'StatsExports', component: load('exports/index'), meta: { title: '导出记录' } },
      { path: '/stats/company-count', name: 'StatsCompanyCount', component: load('stats/company-count/index'), meta: { title: '企业统计' } },
      { path: '/stats/order/:type', name: 'StatsOrder', component: load('stats/order/index'), meta: { title: '订单统计' } },
      { path: '/stats/company-report/:type', name: 'StatsCompanyReport', component: load('stats/company-report/index'), meta: { title: '月报表' } },
      { path: '/stats/sold-activated', name: 'SoldActivated', component: load('stats/sold-activated/index'), meta: { title: '销售激活统计' } },
      { path: '/artisan/real-sync', name: 'RealSync', component: load('artisan/real-sync/index'), meta: { title: 'RD数据同步' } },
      { path: '/flow-pools', name: 'FlowPools', component: load('virtual/flow_pools/index'), meta: { title: '流量池管理' } }
    ]
  },
  { path: '*', redirect: { path: '/home' } }
];

export default routes;
