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

/**
 * 路由缓存机制:
 * 1. 设置路由的meta属性为{ cache: true }，表示需要缓存
 * 2. App.vue中使用RouteCache组件，通过路由的name来进行匹配
 * 3. 路由的name默认是文件名,如果文件名与name不一致,通过defineOptions({ name: 'componentName' })来设置
 */


const router = createRouter({
  history: createWebHistory('/'),
  //   history: createWebHistory(import.meta.env.VITE_APP_URL),
  routes: [
    {
      path: '/',
      redirect: '/welcome'
    },
    {
      path: '/login',
      name: 'LoginPage',
      component: () => import('@/views/login/LoginPage.vue')
    },
    {
      path:'/reset',
      name:'ResetPage',
      component: () => import('@/views/login/ResetPage.vue')
    },
    {
      path: '/signup',
      name: 'SignupPage',
      component: () => import('@/views/login/SignupPage.vue')
    },
    {
      path: '/welcome',
      name: 'WelcomePage',
      component: () => import('@/views/login/WelcomePage.vue')
    },
    {
      path: '/stylist',
      name: 'StylistPage',
      redirect: '/stylist/index',
      component: () => import('@/views/stylist/container.vue'),
      children: [
        {
          path: 'index',
          name: 'index',
          component: () => import('@/views/stylist/index.vue')
        },
        {
          path: 'sex',
          name: 'sex',
          component: () => import('@/views/stylist/sex.vue')
        },
        {
          path: 'dressfor',
          name: 'dressfor',
          component: () => import('@/views/stylist/dressfor.vue')
        },
        {
          path: 'customer',
          name: 'customer',
          component: () => import('@/views/stylist/customer.vue')
        }
      ]
    },
    {
      path: '/asistant',
      name: 'asistant',
      component: () => import('../views/asistant/index.vue'),
      meta: { cache: true }
    },
    {
      path: '/workshop',
      name: 'Workshop',
      component: () => import('../views/Workshop/index.vue'),
      children: [
        {
          path: '/workshop',
          redirect: '/workshop/selectStyle'
        },
        {
          path: '/workshop/selectStyle',
          name: 'SelectStyle',
          component: () => import('../views/Workshop/selectStyle.vue'),
        },
        {
          path: '/workshop/selectModel',
          name: 'SelectModel',
          component: () => import('../views/Workshop/selectModel.vue')
        },
        {
          path: '/workshop/product',
          name: 'Product',
          component: () => import('../views/Workshop/product.vue')
        },
        {
          // 上传照片1
          path: '/workshop/uploadFace',
          name: 'uploadFace',
          component: () => import('../views/Workshop/uploadFace1.vue')
        },
        {
          // 上传照片2
          path: '/workshop/uploadFace2',
          name: 'uploadFace2',
          component: () => import('../views/Workshop/uploadFace2.vue')
        },
        {
          // 自定义创作
          path: '/workshop/customize',
          name: 'customize',
          component: () => import('../views/Workshop/customize.vue')
        },
        {
          // library
          path: '/workshop/library',
          name: 'library',
          component: () => import('../views/Workshop/library.vue')
        },
        {
          path: '/workshop/profile',
          name: 'profile',
          component: () => import('../views/Workshop/profile.vue')
        },
        {
          // creation
          path: '/workshop/creation',
          name: 'creation',
          component: () => import('../views/Workshop/creation/index.vue')
        },
        {
          // 完成创建
          path: '/workshop/end',
          name: 'end',
          component: () => import('../views/Workshop/end.vue')
        }
      ]
    }
  ]
})

export default router
