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

const routes = [
  {
    path: '/',
    redirect: '/dashboard'
  },
  {
    path: '/dashboard',
    name: 'Dashboard',
    component: () => import('@/views/Dashboard.vue'),
    meta: { title: '数据概览' }
  },
  {
    path: '/analysis',
    name: 'FactorAnalysis',
    component: () => import('@/views/FactorAnalysis.vue'),
    meta: { title: '影响因素分析' }
  },
  {
    path: '/prediction',
    name: 'Prediction',
    component: () => import('@/views/Prediction.vue'),
    meta: { title: '缺勤预测' }
  },
  {
    path: '/clustering',
    name: 'Clustering',
    component: () => import('@/views/Clustering.vue'),
    meta: { title: '员工画像' }
  },
  {
    path: '/jdr-analysis',
    name: 'JDRAnalysis',
    component: () => import('@/views/JDRAnalysis.vue'),
    meta: { title: 'JD-R理论分析' }
  }
]

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

router.beforeEach((to, from, next) => {
  document.title = to.meta.title || '员工缺勤分析与预测系统'
  next()
})

export default router
