初始化足球投注平台 MVP Monorepo
包含 NestJS 后端、三端前端、Prisma 数据模型、结算引擎测试与 PRD 文档。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
29
apps/player/src/router/index.ts
Normal file
29
apps/player/src/router/index.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
import { createRouter, createWebHistory } from 'vue-router';
|
||||
import { useAuthStore } from './stores/auth';
|
||||
|
||||
const router = createRouter({
|
||||
history: createWebHistory(),
|
||||
routes: [
|
||||
{ path: '/login', component: () => import('./views/LoginView.vue') },
|
||||
{
|
||||
path: '/',
|
||||
component: () => import('./layouts/MainLayout.vue'),
|
||||
meta: { requiresAuth: true },
|
||||
children: [
|
||||
{ path: '', component: () => import('./views/HomeView.vue') },
|
||||
{ path: 'football', component: () => import('./views/FootballView.vue') },
|
||||
{ path: 'match/:id', component: () => import('./views/MatchDetailView.vue') },
|
||||
{ path: 'bets', component: () => import('./views/MyBetsView.vue') },
|
||||
{ path: 'profile', component: () => import('./views/ProfileView.vue') },
|
||||
],
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
router.beforeEach((to) => {
|
||||
const auth = useAuthStore();
|
||||
if (to.meta.requiresAuth && !auth.token) return '/login';
|
||||
if (to.path === '/login' && auth.token) return '/';
|
||||
});
|
||||
|
||||
export default router;
|
||||
Reference in New Issue
Block a user