lrj
19 小时以前 7ad9c3c93f0cc103347ae2e2429e0122fb512e24
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
import { createRouter, createWebHashHistory, RouteRecordRaw } from 'vue-router'
import { isLoggedIn } from '@/utils/auth'
 
const routes: RouteRecordRaw[] = [
  {
    path: '/',
    component: () => import('@/layout/index.vue'),
    children: [
      { path: '', redirect: '/dashboard' },
      {
        path: '/dashboard',
        name: 'Dashboard',
        component: () => import('@/views/dashboard/index.vue'),
        meta: { title: '工作台', icon: 'Grid' }
      },
 
      {
        path: '/activity',
        name: 'Activity',
        component: () => import('@/views/activity-list.vue'),
        meta: { title: '比赛管理', icon: 'Trophy' }
      },
      {
        path: '/activity/new',
        name: 'ActivityCreate',
        component: () => import('@/views/ActivityForm.vue'),
        meta: { title: '新增比赛', icon: 'Trophy' }
      },
      {
        path: '/activity/edit/:id',
        name: 'ActivityEdit',
        component: () => import('@/views/ActivityForm.vue'),
        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-list.vue'),
        meta: { title: '评委管理', icon: 'UserFilled' }
      },
      {
        path: '/rating-scheme',
        name: 'RatingScheme',
        component: () => import('@/views/rating-list.vue'),
        meta: { title: '评分模板', icon: 'Document' }
      },
      {
        path: '/rating-scheme/new',
        name: 'RatingSchemeCreate',
        component: () => import('@/views/rating-detail.vue'),
        meta: { title: '新建评分模板', hidden: true }
      },
      {
        path: '/rating-scheme/edit/:id',
        name: 'RatingSchemeEdit',
        component: () => import('@/views/rating-detail.vue'),
        meta: { title: '编辑评分模板', hidden: true }
      },
      {
        path: '/player',
        name: 'Player',
        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',
        name: 'ActivityPlayerRating',
        component: () => import('@/views/activity-player/rating.vue'),
        meta: { title: '评分详情', icon: 'Edit' }
      },
      {
        path: '/carousel',
        name: 'Carousel',
        component: () => import('@/views/carousel/index.vue'),
        meta: { title: '新闻与推广', icon: 'Picture' }
      },
      {
        path: '/region',
        name: 'Region',
        component: () => import('@/views/region/index.vue'),
        meta: { title: '区域管理', icon: 'Location' }
      },
      {
        path: '/employee',
        name: 'Employee',
        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' }
      },
 
    ]
  },
  {
    path: '/login',
    name: 'Login',
    component: () => import('@/views/login/index.vue'),
    meta: { title: '登录' }
  }
]
 
const router = createRouter({
  history: createWebHashHistory(),
  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