Files
MBTI_wang/h5-vue/src/router/index.ts
Ghost a411bf7b21 高考版优化
审核模式优化
2026-04-29 18:01:26 +08:00

113 lines
3.1 KiB
TypeScript

import { createRouter, createWebHistory } from 'vue-router'
import TabLayout from '@/layouts/TabLayout.vue'
/** 与 miniprogram/app.json pages 数组顺序一致(用于统计迁移进度) */
export const MINI_PAGE_PATHS = [
'pages/index/index',
'pages/index/camera',
'pages/index/upload',
'pages/index/result',
'pages/test-select/index',
'pages/ai-test/index',
'pages/test/mbti',
'pages/test/sbti',
'pages/test/disc',
'pages/test/pdp',
'pages/result/mbti',
'pages/result/sbti',
'pages/result/disc',
'pages/result/pdp',
'pages/result/resume',
'pages/purchase/index',
'pages/recharge/index',
'pages/enterprise/index',
'pages/enterprise/resume-history',
'pages/profile/index',
'pages/user-profile/index',
'pages/history/index',
'pages/order/index',
'pages/phone-auth/index',
'pages/promo/index',
'pages/promo/poster',
'pages/promo/withdrawals',
'pages/match-job/index',
'pages/gaokao/index',
'pages/gaokao/form',
'pages/gaokao/report',
'pages/ai-chat/index',
'pages/ai-chat/report',
'pages/ai-chat/history',
'pages/webview/index',
] as const
export const TAB_PATHS = new Set([
'pages/index/index',
'pages/index/camera',
'pages/profile/index',
])
const IndexHome = () => import('@/views/tab/IndexHome.vue')
const CameraPage = () => import('@/views/tab/CameraPage.vue')
const ProfilePage = () => import('@/views/tab/ProfilePage.vue')
const PageStub = () => import('@/views/stub/PageStub.vue')
const TestSelectPage = () => import('@/views/pages/TestSelectPage.vue')
const MbtiTestPage = () => import('@/views/test/MbtiTestPage.vue')
const STUB_EXCLUDE = new Set<string>(['pages/test-select/index', 'pages/test/mbti'])
const stubRoutes = MINI_PAGE_PATHS.filter(
(p) => !TAB_PATHS.has(p) && !STUB_EXCLUDE.has(p)
).map((path) => ({
path: '/' + path,
name: 'stub-' + path.replace(/\//g, '-'),
component: PageStub,
meta: { miniPath: path, title: path.split('/').pop() || path },
}))
const router = createRouter({
history: createWebHistory(import.meta.env.BASE_URL),
routes: [
{
path: '/',
component: TabLayout,
redirect: '/pages/index/index',
children: [
{
path: 'pages/index/index',
name: 'home',
component: IndexHome,
meta: { miniPath: 'pages/index/index', tab: true },
},
{
path: 'pages/index/camera',
name: 'camera',
component: CameraPage,
meta: { miniPath: 'pages/index/camera', tab: true },
},
{
path: 'pages/profile/index',
name: 'profile',
component: ProfilePage,
meta: { miniPath: 'pages/profile/index', tab: true },
},
],
},
{
path: '/pages/test-select/index',
name: 'test-select',
component: TestSelectPage,
meta: { miniPath: 'pages/test-select/index', title: '选择测试' },
},
{
path: '/pages/test/mbti',
name: 'test-mbti',
component: MbtiTestPage,
meta: { miniPath: 'pages/test/mbti', title: 'MBTI 测试' },
},
...stubRoutes,
{ path: '/:pathMatch(.*)*', redirect: '/pages/index/index' },
],
})
export default router