index.js 1.48 KB
/*
 * @Date: 2025-10-30 10:29:15
 * @LastEditors: hookehuyr hookehuyr@gmail.com
 * @LastEditTime: 2025-11-04 20:35:35
 * @FilePath: /stdj_h5/src/router/index.js
 * @Description: 文件描述
 */
import { createRouter, createWebHashHistory } from 'vue-router'

const routes = [
  {
    path: '/',
    name: 'Splash',
    component: () => import('../views/Splash.vue')
  },
  {
    path: '/home',
    name: 'Home',
    component: () => import('../views/Home.vue')
  },
  {
    path: '/masters',
    name: '三師七證',
    component: () => import('../views/Masters.vue')
  },
  {
    path: '/masters/:id',
    name: '三師七證详情',
    component: () => import('../views/MastersDetail.vue')
  },
  {
    path: '/news/:id',
    name: 'NewsDetail',
    component: () => import('../views/NewsDetail.vue')
  },
  {
    path: '/students',
    name: '戒子',
    component: () => import('../views/Students.vue')
  },
  {
    path: '/volunteers',
    name: '义工',
    component: () => import('../views/Volunteers.vue')
  },
  {
    path: '/:pathMatch(.*)*',
    name: 'NotFound',
    component: () => import('../views/NotFound.vue')
  }
]

const router = createRouter({
  history: createWebHashHistory('/index.html'),
  routes,
})

// 路由守卫
router.beforeEach((to, from, next) => {
  // 设置页面标题
  if (to.meta.title) {
    document.title = to.meta.title
  }

  // 这里可以添加权限验证逻辑
  next()
})

router.afterEach(() => {
  // 路由跳转后的逻辑
})

export default router