Files
lanecarford_front/src/router/index.ts

201 lines
5.5 KiB
TypeScript
Raw Normal View History

2025-10-09 09:29:36 +08:00
import { createRouter, createWebHistory } from 'vue-router'
2025-10-31 14:41:07 +08:00
import { useGenerateStore } from '@/stores/modules/generate'
2025-10-31 14:41:40 +08:00
const VerifyIDs = (num: number) => {
2025-11-17 15:17:27 +08:00
return true
2025-10-31 14:41:40 +08:00
const ids = [
!!useGenerateStore().customerId,
!!useGenerateStore().visitRecordId,
!!useGenerateStore().styleId,
// !!useGenerateStore().modelPhotoId,
true,
!!useGenerateStore().originalTryOnId,
];
return ids.splice(0, num).every(id => id) ? true : "/stylist/customer";
}
2025-10-21 11:28:12 +08:00
/**
* :
* 1. meta属性为{ cache: true }
* 2. App.vue中使用RouteCache组件name来进行匹配
* 3. name默认是文件名,name不一致,defineOptions({ name: 'componentName' })
2025-10-31 14:41:07 +08:00
*
*
* meta{ verify: => boolean || string }
* 1. boolean true false
* 2. string path
2025-10-21 11:28:12 +08:00
*/
2025-10-31 14:41:07 +08:00
/** id
* @param num id的数量1-5
* 1. id
* 2. id
* 3. id
* 4. id
* 5. 穿id-AI魔改
* @returns boolean
*/
2025-10-09 09:29:36 +08:00
const router = createRouter({
history: createWebHistory('/'),
// history: createWebHistory(import.meta.env.VITE_APP_URL),
2025-10-09 09:29:36 +08:00
routes: [
{
path: '/',
redirect: '/welcome'
},
{
path: '/login',
2025-10-13 10:13:54 +08:00
name: 'LoginPage',
component: () => import('@/views/login/LoginPage.vue')
},
2025-10-22 14:03:57 +08:00
{
path:'/reset',
name:'ResetPage',
component: () => import('@/views/login/ResetPage.vue')
},
{
path: '/signup',
2025-10-13 10:13:54 +08:00
name: 'SignupPage',
component: () => import('@/views/login/SignupPage.vue')
},
2025-10-13 10:13:54 +08:00
{
path: '/welcome',
name: 'WelcomePage',
component: () => import('@/views/login/WelcomePage.vue')
},
{
path: '/customer',
name: 'customer',
component: () => import('@/views/login/customer.vue'),
},
2025-10-14 16:42:09 +08:00
{
path: '/asistant',
name: 'asistant',
2025-10-21 11:21:15 +08:00
component: () => import('../views/asistant/index.vue'),
2025-10-31 14:41:07 +08:00
meta: { cache: true, verify: ()=> VerifyIDs(2) }
2025-10-14 16:42:09 +08:00
},
{
path: '/workshop',
name: 'Workshop',
component: () => import('../views/Workshop/index.vue'),
children: [
// {
// path: '/workshop',
// redirect: '/workshop/selectStyle'
// },
{
path: '/workshop/home',
name: 'Home',
component: () => import('@/views/Workshop/home.vue')
},
{
path: '/workshop/homeNav',
name: 'HomeNav',
component: () => import('@/views/Workshop/homeNav.vue')
},
{
path: '/workshop/stylist',
name: 'StylistPage',
redirect: '/workshop/stylist/index',
component: () => import('@/views/stylist/container.vue'),
children: [
{
path: 'index',
name: 'index',
component: () => import('@/views/stylist/index.vue'),
meta: { verify: ()=> VerifyIDs(2) }
},
{
path: 'sex',
name: 'sex',
component: () => import('@/views/stylist/sex.vue'),
meta: { verify: ()=> VerifyIDs(2) }
},
{
path: 'dressfor',
name: 'dressfor',
component: () => import('@/views/stylist/dressfor.vue'),
meta: { verify: ()=> VerifyIDs(2) }
},
]
},
{
path: '/workshop/selectStyle',
name: 'SelectStyle',
2025-10-24 11:48:15 +08:00
component: () => import('../views/Workshop/selectStyle.vue'),
2025-10-31 14:41:07 +08:00
meta: { verify: ()=> VerifyIDs(2) }
},
{
path: '/workshop/selectModel',
name: 'SelectModel',
2025-10-31 14:41:07 +08:00
component: () => import('../views/Workshop/selectModel.vue'),
meta: { verify: ()=> VerifyIDs(3) }
},
{
2025-10-21 13:46:27 +08:00
path: '/workshop/product',
name: 'Product',
2025-10-31 14:41:07 +08:00
component: () => import('../views/Workshop/product.vue'),
meta: { verify: ()=> VerifyIDs(4) }
},
2025-11-17 17:33:32 +08:00
{
// 推荐try on
path: '/workshop/recommended',
name: 'recommended',
component: () => import('../views/Workshop/recommended.vue'),
meta: { verify: ()=> VerifyIDs(5) }
},
2025-10-13 10:13:54 +08:00
{
2025-10-16 13:57:00 +08:00
// 上传照片1
2025-10-13 10:13:54 +08:00
path: '/workshop/uploadFace',
name: 'uploadFace',
2025-10-31 14:41:07 +08:00
component: () => import('../views/Workshop/uploadFace1.vue'),
meta: { verify: ()=> VerifyIDs(5) }
2025-10-16 13:57:00 +08:00
},
{
// 上传照片2
path: '/workshop/uploadFace2',
name: 'uploadFace2',
2025-10-31 14:41:07 +08:00
component: () => import('../views/Workshop/uploadFace2.vue'),
meta: { verify: ()=> VerifyIDs(5) }
2025-10-13 10:13:54 +08:00
},
{
// 自定义创作
path: '/workshop/customize',
name: 'customize',
2025-10-31 14:41:07 +08:00
component: () => import('../views/Workshop/customize.vue'),
meta: { verify: ()=> VerifyIDs(5) }
2025-10-13 10:13:54 +08:00
},
2025-10-16 11:01:54 +08:00
{
// library
path: '/workshop/library',
2025-10-21 11:21:15 +08:00
name: 'library',
2025-10-31 14:41:07 +08:00
component: () => import('../views/Workshop/library.vue'),
meta: { verify: ()=> VerifyIDs(2) }
2025-10-21 11:21:15 +08:00
},
2025-10-21 16:40:13 +08:00
{
path: '/workshop/profile',
name: 'profile',
2025-10-31 14:41:07 +08:00
component: () => import('../views/Workshop/profile.vue'),
meta: { verify: ()=> VerifyIDs(1) }
2025-10-21 16:40:13 +08:00
},
2025-10-21 11:21:15 +08:00
{
// creation
path: '/workshop/creation',
name: 'creation',
2025-10-31 14:41:07 +08:00
component: () => import('../views/Workshop/creation/index.vue'),
meta: { verify: ()=> VerifyIDs(2) }
2025-10-16 11:01:54 +08:00
},
2025-10-13 10:13:54 +08:00
{
// 完成创建
path: '/workshop/end',
name: 'end',
2025-10-31 14:41:07 +08:00
component: () => import('../views/Workshop/end.vue'),
meta: { verify: ()=> VerifyIDs(2) }
2025-10-13 10:13:54 +08:00
}
]
}
2025-10-09 09:29:36 +08:00
]
})
export default router