import Vue from 'vue'
import Router from 'vue-router'
import Layout from '../layout/index'

Vue.use(Router)

export const constantRouterMap = [
  {
    path: '/login',
    meta: { title: '登录', noCache: true },
    component: (resolve) => require(['@/views/login'], resolve),
    hidden: true
  },
  {
    path: '/404',
    component: (resolve) => require(['@/views/features/404'], resolve),
    hidden: true
  },
  {
    path: '/401',
    component: (resolve) => require(['@/views/features/401'], resolve),
    hidden: true
  },
  {
    path: '/redirect',
    component: Layout,
    hidden: true,
    children: [
      {
        path: '/redirect/:path*',
        component: (resolve) => require(['@/views/features/redirect'], resolve)
      }
    ]
  },
  {
    path: '/',
    component: Layout,
    redirect: '/data_statistics',
    meta: {
      title: '数据统计',
      icon: 'index'
    },
    children: [
      {
        path: 'data_statistics',
        component: (resolve) => require(['@/views/home/home'], resolve),
        name: 'data_statistics',
        meta: { title: '数据统计' }
      },
      {
        path: 'data_forms',
        component: (resolve) => require(['@/views/home/data_forms'], resolve),
        name: 'data_forms',
        meta: { title: '销量统计' }
      },
      {
        path: 'data_tables',
        component: (resolve) => require(['@/views/home/data_tables'], resolve),
        name: 'data_tables',
        meta: { title: '桌台统计' }
      },
      {
        path: 'data_credit',
        component: (resolve) => require(['@/views/home/data_credit'], resolve),
        name: 'data_credit',
        meta: { title: '挂账管理' }
      },
      {
        path: 'data_creditDetail',
        component: (resolve) => require(['@/views/home/data_creditDetail'], resolve),
        name: 'data_creditDetail',
        hidden: true,
        meta: { title: '挂账明细' }
      },
      {
        path: 'data_record',
        component: (resolve) => require(['@/views/home/data_record'], resolve),
        name: 'data_record',
        meta: { title: '交班记录' }
      }
    ]
  },
  {
    path: '/user',
    component: Layout,
    hidden: true,
    redirect: 'noredirect',
    children: [
      {
        path: 'center',
        component: (resolve) => require(['@/views/system/user/center'], resolve),
        name: '个人中心',
        meta: { title: '个人中心' }
      }
    ]
  }
]

export default new Router({
  // mode: 'hash',
  mode: 'history',
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRouterMap
})
