import { createRouter, createWebHistory } from 'vue-router'
import Home from '../components/Home.vue'
import PrivacyAgreement from '../components/PrivacyAgreement.vue'
import UserAgreement from '../components/UserAgreement.vue'
import Dashboard from '../components/Dashboard.vue'
import HowToUse from '../components/HowToUse.vue'
import CommunityRequest from '../components/CommunityRequest.vue'
import PartnerRequest from '../components/PartnerRequest.vue'
import ImageRecognition from '../components/ImageRecognition.vue'
import SystemHealth from '../components/SystemHealth.vue'

const routes = [
  {
    path: '/',
    name: 'Home',
    component: Home
  },
  {
    path: '/privacy',
    name: 'Privacy',
    component: PrivacyAgreement,
    meta: {
      title: '隐私政策'
    }
  },
  {
    path: '/agreement',
    name: 'Agreement',
    component: UserAgreement,
    meta: {
      title: '用户服务协议'
    }
  },
  {
    path: '/dashboard',
    name: 'Dashboard',
    component: Dashboard,
    meta: {
      title: '数据大屏'
    }
  },
  {
    path: '/how-to-use',
    name: 'HowToUse',
    component: HowToUse,
    meta: {
      title: '快递服务流程'
    }
  },
  {
    path: '/community-request',
    name: 'CommunityRequest',
    component: CommunityRequest,
    meta: {
      title: '小区开通申请'
    }
  },
  {
    path: '/partner-request',
    name: 'PartnerRequest',
    component: PartnerRequest,
    meta: {
      title: '申请成为服务商/运营商'
    }
  },
  {
    path: '/image-recognition',
    name: 'ImageRecognition',
    component: ImageRecognition,
    meta: {
      title: '蜂快AI·快递取件码识别'
    }
  },
  {
    path: '/system-health',
    name: 'SystemHealth',
    component: SystemHealth,
    meta: {
      title: '系统健康状态',
      requiresAuth: true
    }
  }
]

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

router.beforeEach((to, from, next) => {
  document.title = '蜂快到家'
  
  if (to.meta.title) {
    document.title = to.meta.title
  }
  
  next()
})

export default router 