lrj
昨天 7ad9c3c93f0cc103347ae2e2429e0122fb512e24
web/src/router/index.ts
@@ -1,4 +1,5 @@
import { createRouter, createWebHashHistory, RouteRecordRaw } from 'vue-router'
import { isLoggedIn } from '@/utils/auth'
const routes: RouteRecordRaw[] = [
  {
@@ -12,17 +13,12 @@
        component: () => import('@/views/dashboard/index.vue'),
        meta: { title: '工作台', icon: 'Grid' }
      },
      {
        path: '/activity',
        name: 'Activity',
        component: () => import('@/views/activity/index.vue'),
        component: () => import('@/views/activity-list.vue'),
        meta: { title: '比赛管理', icon: 'Trophy' }
      },
      {
        path: '/activity/:id',
        name: 'ActivityDetail',
        component: () => import('@/views/ActivityDetail.vue'),
        meta: { title: '比赛详情', icon: 'Trophy' }
      },
      {
        path: '/activity/new',
@@ -37,34 +33,46 @@
        meta: { title: '编辑比赛', icon: 'Trophy' }
      },
      {
        path: '/activity/:id',
        name: 'ActivityDetail',
        component: () => import('@/views/ActivityDetail.vue'),
        meta: { title: '比赛详情', icon: 'Trophy' }
      },
      {
        path: '/judge',
        name: 'Judge',
        component: () => import('@/views/judge/index.vue'),
        component: () => import('@/views/judge-list.vue'),
        meta: { title: '评委管理', icon: 'UserFilled' }
      },
      {
        path: '/rating-scheme',
        name: 'RatingScheme',
        component: () => import('@/views/rating/index.vue'),
        meta: { title: '评分模板', icon: 'Score' }
        component: () => import('@/views/rating-list.vue'),
        meta: { title: '评分模板', icon: 'Document' }
      },
      {
        path: '/rating-scheme/new',
        name: 'RatingSchemeCreate',
        component: () => import('@/views/rating/Form.vue'),
        meta: { title: '新增评分模板', icon: 'Score' }
        component: () => import('@/views/rating-detail.vue'),
        meta: { title: '新建评分模板', hidden: true }
      },
      {
        path: '/rating-scheme/edit/:id',
        name: 'RatingSchemeEdit',
        component: () => import('@/views/rating/Form.vue'),
        meta: { title: '编辑评分模板', icon: 'Score' }
        component: () => import('@/views/rating-detail.vue'),
        meta: { title: '编辑评分模板', hidden: true }
      },
      {
        path: '/player',
        name: 'Player',
        component: () => import('@/views/player/index.vue'),
        meta: { title: '比赛报名', icon: 'UserFilled' }
        component: () => import('@/views/check-list.vue'),
        meta: { title: '参赛人员', icon: 'UserFilled' }
      },
      {
        path: '/player/:id/detail',
        name: 'PlayerDetail',
        component: () => import('@/views/check-detail.vue'),
        meta: { title: '参赛人员详情' }
      },
      {
        path: '/activity-player/:id/rating',
@@ -87,9 +95,40 @@
      {
        path: '/employee',
        name: 'Employee',
        component: () => import('@/views/employee/index.vue'),
        meta: { title: '员工管理', icon: 'Avatar' }
      }
        component: () => import('@/views/employee-list.vue'),
        meta: { title: '员工管理', icon: 'User' }
      },
      {
        path: '/project-review',
        name: 'ProjectReview',
        component: () => import('@/views/review-list.vue'),
        meta: { title: '项目评审', icon: 'View' }
      },
      {
        path: '/project-review/:id/detail',
        name: 'ProjectReviewDetail',
        component: () => import('@/views/review-detail.vue'),
        meta: { title: '项目评审详情', hidden: true }
      },
      {
        path: '/review',
        name: 'Review',
        component: () => import('@/views/judge-review-list.vue'),
        meta: { title: '评委评审', icon: 'Edit' }
      },
      {
        path: '/review/:id/detail',
        name: 'ReviewDetail',
        component: () => import('@/views/judge-review-detail.vue'),
        meta: { title: '评委评审详情', hidden: true }
      },
      {
        path: '/competition-promotion',
        name: 'CompetitionPromotion',
        component: () => import('@/views/next-list.vue'),
        meta: { title: '比赛晋级', icon: 'Promotion' }
      },
    ]
  },
  {
@@ -105,4 +144,28 @@
  routes
})
// 路由守卫
router.beforeEach((to, from, next) => {
  // 如果是登录页面,直接放行
  if (to.path === '/login') {
    // 如果已经登录,重定向到首页
    if (isLoggedIn()) {
      next('/')
    } else {
      next()
    }
    return
  }
  // 检查是否已登录
  if (!isLoggedIn()) {
    // 未登录,重定向到登录页
    next('/login')
    return
  }
  // 已登录,正常访问
  next()
})
export default router