2026-04-20 11:21:21 +08:00
|
|
|
|
import { createRouter, createWebHistory } from 'vue-router'
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 路由缓存机制:
|
|
|
|
|
|
* 1. 设置路由的meta属性为{ cache: true },表示需要缓存
|
|
|
|
|
|
* 2. App.vue中使用RouteCache组件,通过路由的name来进行匹配
|
|
|
|
|
|
* 3. 路由的name默认是文件名,如果文件名与name不一致,通过defineOptions({ name: 'componentName' })来设置
|
|
|
|
|
|
*/
|
|
|
|
|
|
const router = createRouter({
|
2026-04-22 10:30:55 +08:00
|
|
|
|
history: createWebHistory('/'),
|
|
|
|
|
|
// history: createWebHistory(import.meta.env.VITE_APP_URL),
|
|
|
|
|
|
routes: [
|
|
|
|
|
|
{
|
|
|
|
|
|
path: '/',
|
|
|
|
|
|
name: 'home',
|
|
|
|
|
|
component: () => import('../views/home/index.vue')
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
path: '/collectionStory',
|
|
|
|
|
|
name: 'collectionStory',
|
|
|
|
|
|
component: () => import('../views/collectionStory/index.vue')
|
|
|
|
|
|
// {
|
|
|
|
|
|
// path: '/',
|
|
|
|
|
|
// redirect: '/welcome'
|
|
|
|
|
|
// },
|
|
|
|
|
|
// {
|
|
|
|
|
|
// path: '/asistant',
|
|
|
|
|
|
// name: 'asistant',
|
|
|
|
|
|
// component: () => import('../views/asistant/index.vue'),
|
|
|
|
|
|
// meta: { cache: true, verify: () => VerifyIDs(2) }
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
path: '/settings',
|
|
|
|
|
|
name: 'settings',
|
|
|
|
|
|
component: () => import('@/views/setting/index.vue'),
|
|
|
|
|
|
meta: { cache: true }
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
path: '/:pathMatch(.*)',
|
|
|
|
|
|
name: '404',
|
|
|
|
|
|
component: () => import('../views/404.vue')
|
|
|
|
|
|
}
|
|
|
|
|
|
]
|
2026-04-20 11:21:21 +08:00
|
|
|
|
history: createWebHistory('/'),
|
|
|
|
|
|
// history: createWebHistory(import.meta.env.VITE_APP_URL),
|
|
|
|
|
|
routes: [
|
2026-04-20 14:02:55 +08:00
|
|
|
|
{
|
|
|
|
|
|
path: '/',
|
|
|
|
|
|
name: 'home',
|
|
|
|
|
|
component: () => import('../views/home/index.vue'),
|
|
|
|
|
|
},
|
2026-04-20 14:06:02 +08:00
|
|
|
|
{
|
|
|
|
|
|
path: '/collectionStory',
|
|
|
|
|
|
name: 'collectionStory',
|
|
|
|
|
|
component: () => import('../views/collectionStory/index.vue'),
|
|
|
|
|
|
},
|
2026-04-21 15:57:37 +08:00
|
|
|
|
{
|
|
|
|
|
|
path: '/brand',
|
|
|
|
|
|
name: 'brand',
|
|
|
|
|
|
component: () => import('../views/brand/index.vue'),
|
|
|
|
|
|
},
|
2026-04-20 11:21:21 +08:00
|
|
|
|
{
|
|
|
|
|
|
path: '/:pathMatch(.*)',
|
|
|
|
|
|
name: '404',
|
|
|
|
|
|
component: () => import('../views/404.vue'),
|
|
|
|
|
|
},
|
|
|
|
|
|
]
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
router.beforeEach((to, from, next) => {
|
2026-04-22 10:30:55 +08:00
|
|
|
|
next()
|
2026-04-20 11:21:21 +08:00
|
|
|
|
})
|
|
|
|
|
|
|
2026-04-22 10:30:55 +08:00
|
|
|
|
router.afterEach(() => {})
|
2026-04-20 11:21:21 +08:00
|
|
|
|
|
|
|
|
|
|
export default router
|