import Vue from 'vue';
import VueRouter from 'vue-router';

Vue.use(VueRouter);

const routes = [
  {
    path: '/',
    name: 'home',
    redirect: '/monitor',
  },
  {
    path: '/pageBox',
    component: () => import('@/views/pageBox/index.vue'),
    redirect: '/monitor',
    children: [
      {
        path: '/monitor',
        name: 'monitor',
        meta: { title: '运营监控数据可视化' },
        component: () => import('@/views/pageMonitor/index.vue'),
      },
      {
        path: '/scheduling',
        name: 'scheduling',
        meta: { title: '运营监控数据可视化' },
        component: () => import('@/views/pageScheduling/index.vue'),
      },
      {
        path: '/operation',
        name: 'operation',
        meta: { title: '首台率数据可视化' },
        component: () => import('@/views/pageOperation/index.vue'),
      },
      {
        path: '/room',
        name: 'room',
        meta: { title: '手术间利用率数据可视化' },
        component: () => import('@/views/pageRoom/index.vue'),
      },
    ],
  },
  {
    path: '/waitList',
    name: 'waitList',
    meta: { title: '家属等候大屏' },
    component: () => import('@/views/waitList/index.vue'),
  },
  {
    path: '/scheduleList',
    name: 'scheduleList',
    meta: { title: '手术排程' },
    component: () => import('@/views/scheduleList/index.vue'),
  },
  {
    path: '/melon',
    name: 'melon',
    meta: { title: '手术排程' },
    component: () => import('@/views/pageMelon/index.vue'),
  },
];

const router = new VueRouter({
  routes,
});

router.beforeEach((to, from, next) => {
  document.title = to.meta.title;
  next();
});

export default router;
