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

// 导入登录相关组件
const LoginPage = () => import('@/views/login/LoginPage.vue')
const RegisterPage = () => import('@/views/login/RegisterPage.vue')
const ChangePasswordPage = () => import('@/views/login/ChangePasswordPage.vue')

// 认证相关路由配置
export const authRoutes: RouteRecordRaw[] = [
  {
    path: '/login',
    name: 'Login',
    component: LoginPage,
    meta: {
      title: '用户登录',
      requiresAuth: false,
      layout: 'blank', // 使用空白布局
    },
  },
  {
    path: '/register',
    name: 'Register',
    component: RegisterPage,
    meta: {
      title: '用户注册',
      requiresAuth: false,
      layout: 'blank',
    },
  },
  {
    path: '/change-password',
    name: 'ChangePassword',
    component: ChangePasswordPage,
    meta: {
      title: '修改密码',
      requiresAuth: true,
      allowedRoles: ['admin', 'manager', 'customer'],
    },
  }
]

// 创建认证路由实例
const authRouter = createRouter({
  history: createWebHistory(),
  routes: authRoutes,
})

export default authRouter
