import { createRouter, createWebHistory } from 'vue-router'

const routes = [
  {
    path: '/',
    redirect: '/idle'
  },
  {
    path: '/idle',
    name: 'Idle',
    component: () => import('@/views/idle/Index.vue'),
    meta: { title: '待机展示' }
  },
  {
    path: '/menu',
    name: 'Menu',
    component: () => import('@/views/menu/Index.vue'),
    meta: { title: '主菜单' }
  },
  {
    path: '/visitor',
    name: 'Visitor',
    component: () => import('@/views/visitor/Index.vue'),
    meta: { title: '访客登记' }
  },
  {
    path: '/visitor/appointment',
    name: 'VisitorAppointment',
    component: () => import('@/views/visitor/Appointment.vue'),
    meta: { title: '预约核验' }
  },
  {
    path: '/visitor/appointment-confirm',
    name: 'VisitorAppointmentConfirm',
    component: () => import('@/views/visitor/AppointmentConfirm.vue'),
    meta: { title: '预约确认' }
  },
  {
    path: '/visitor/walk-in',
    name: 'VisitorWalkIn',
    component: () => import('@/views/visitor/WalkIn.vue'),
    meta: { title: '现场登记' }
  },
  {
    path: '/visitor/success',
    name: 'VisitorSuccess',
    component: () => import('@/views/visitor/Success.vue'),
    meta: { title: '登记成功' }
  },
  {
    path: '/recognition/result',
    name: 'RecognitionResult',
    component: () => import('@/views/recognition/Result.vue'),
    meta: { title: '识别结果' }
  },
  {
    path: '/navigation',
    name: 'Navigation',
    component: () => import('@/views/navigation/Index.vue'),
    meta: { title: '路线引导' }
  },
  {
    path: '/navigation/status',
    name: 'NavigationStatus',
    component: () => import('@/views/navigation/Status.vue'),
    meta: { title: '导航状态' }
  },
  {
    path: '/notice',
    name: 'Notice',
    component: () => import('@/views/notice/Index.vue'),
    meta: { title: '通知公告' }
  },
  {
    path: '/call-staff',
    name: 'CallStaff',
    component: () => import('@/views/call-staff/Index.vue'),
    meta: { title: '呼叫工作人员' }
  },
  {
    path: '/system-info',
    name: 'SystemInfo',
    component: () => import('@/views/system/Info.vue'),
    meta: { title: '系统信息' }
  }
]

const router = createRouter({
  history: createWebHistory(),
  routes
})

router.beforeEach((to, from, next) => {
  if (to.meta.title) {
    document.title = to.meta.title + ' - 迎宾机器人'
  }
  next()
})

export default router
