123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151 |
- import { createRouter, createWebHistory } from 'vue-router'
- import { defineAsyncComponent } from 'vue'
- // import Home from '@/views/Home.vue'
- // import HomeView from '@/views/HomeView.vue'
- //路由异步加载
- //主页框架
- const Home = () => import('@/views/Home.vue')
- //首页详细内容
- const HomeView = () => import('@/views/HomeView.vue')
- //科普内容
- const PopularizationScience = () => import('@/views/PopularizationScience.vue')
- const Community = () => import('@/views/Community.vue')
- // 组件异步懒加载方法
- // const _import = (path: string) =>
- // defineAsyncComponent(() => import(`../views/${path}.vue`))
- const routes = [
- {
- path: '/',
- name: 'home',
- // component: Home,
- component: Home,
- redirect: "/homeView",
- children: [{
- path: 'homeView',
- name: 'homeView',
- component: HomeView
- // component: _import('HomeView')
- },
- {
- path: 'popularizationScience',
- name: 'popularizationScience',
- component: PopularizationScience
- },
- {
- path: 'community',
- name: 'community',
- component: () => import('@/views/Community.vue')
- }, {
- path: 'plan',
- name: 'plan',
- component: () => import('@/views/Plan.vue')
- }, {
- path: 'testRecord',
- name: 'testRecord',
- component: () => import('@/views/TestRecord.vue')
- }, {
- path: 'report/:planId/:flag/:name',
- name: 'report',
- component: () => import('@/views/Report.vue')
- },
- {
- path: 'login',
- name: 'login',
- component: () => import('@/views/Login.vue')
- },
- {
- path: 'updatePas',
- name: 'updatePas',
- component: () => import('@/views/UpdatePas.vue')
- },
- {
- path: 'register',
- name: 'register',
- component: () => import('@/views/Register.vue')
- },
- {
- path: 'scale/:planId/:planName/:flag/:flagName/:isComplate',
- name: 'scale',
- component: () => import('@/views/Scale.vue')
- },
- //量表或认知任务详情页
- {
- path: 'scaleDetail/:planId/:planName/:flag/:type',
- name: 'scaleDetail',
- component: () => import('@/views/ScaleDetail.vue')
- },
- {
- path: 'scaleMid/:planId/:planName/:flag/:flagName/:num',
- name: 'scaleMid',
- component: () => import('@/views/ScaleMid.vue')//量表中间件
- },
- //认知任务
- {
- path: 'cognize/:planId/:planName/:flag/:type',
- name: 'cognize',
- component: () => import('@/views/Cognize.vue')
- }
- ]
- // component: HomeView
- },
- {
- path: '/cognizeGoNoGo/:currentType/:planId/:planName/:flag/:flagName/:num',
- name: 'cognizeGoNoGo',
- component: () => import('@/views/CognizeGoNoGo.vue')
- }, {
- path: '/cognizeFaceDot/:planId/:planName/:flag/:flagName/:formalTest',
- name: 'cognizeFaceDot',
- component: () => import('@/views/CognizeFaceDot.vue')
- }, {
- path: '/shapeIntuition_random/:planId/:planName/:flag/:flagName:/:formalTest',
- name: 'shapeIntuitionRandom',
- component: () => import('@/views/shapeIntuition_random.vue')
- },
- {
- path: '/ETBexperiment_new/:planId/:planName/:flag/:flagName:/:formalTest',
- name: 'ETBexperimentNew',
- component: () => import('@/views/ETBexperiment_new.vue')
- },
- {
- path: '/Stroop/:planId/:planName/:flag/:flagName:/:formalTest',
- name: 'Stroop',
- component: () => import('@/views/Stroop.vue')
- }
- ]
- const router = createRouter({
- // history: createWebHistory(import.meta.env.BASE_URL),
- history: createWebHistory("/highLevelIntellectual/"),
- //highLevelIntellectual
- // history: createWebHistory('/pc/'),
- routes
- })
- //页面滚动到最顶部
- router.beforeEach((to, from, next) => {
- window.scrollTo(0, 0);
- /** meta是定义路由时路由的属性 */
- if (to.meta.title) {
- (document as any).title = to.meta.title;
- }
- next();
- });
- export default router
|