frontend init

This commit is contained in:
2026-02-15 17:56:28 +01:00
parent 7afe2da63e
commit b52429c250
33 changed files with 1688 additions and 0 deletions

47
front/src/router/index.ts Normal file
View File

@@ -0,0 +1,47 @@
import { createRouter, createWebHistory } from 'vue-router'
import HomeView from '../views/HomeView.vue'
import { useAuthStore } from '@/stores/auth'
const router = createRouter({
history: createWebHistory(import.meta.env.BASE_URL),
routes: [
{
path: '/',
name: 'home',
component: HomeView,
meta: { requiresAuth: false },
},
{
path: '/about',
name: 'about',
component: () => import('../views/AboutView.vue'),
meta: { requiresAuth: false },
},
{
path: '/login',
name: 'login',
component: () => import('../views/LoginView.vue'),
meta: { guestOnly: true },
},
{
path: '/signup',
name: 'signup',
component: () => import('../views/SignupView.vue'),
meta: { guestOnly: true },
},
],
})
router.beforeEach((to) => {
const auth = useAuthStore()
if (to.meta.guestOnly && auth.isAuthenticated) {
return '/'
}
if (to.meta.requiresAuth && !auth.isAuthenticated) {
return '/login'
}
})
export default router