initial commit - LeDiscord plateforme des copains

This commit is contained in:
EvanChal
2025-08-21 00:28:21 +02:00
commit b7a84a53aa
93 changed files with 16247 additions and 0 deletions

View File

@@ -0,0 +1,143 @@
import { createRouter, createWebHistory } from 'vue-router'
import { useAuthStore } from '@/stores/auth'
// Views
import Home from '@/views/Home.vue'
import Login from '@/views/Login.vue'
import Register from '@/views/Register.vue'
import Events from '@/views/Events.vue'
import EventDetail from '@/views/EventDetail.vue'
import Albums from '@/views/Albums.vue'
import AlbumDetail from '@/views/AlbumDetail.vue'
import Vlogs from '@/views/Vlogs.vue'
import VlogDetail from '@/views/VlogDetail.vue'
import Posts from '@/views/Posts.vue'
import Profile from '@/views/Profile.vue'
import UserProfile from '@/views/UserProfile.vue'
import Stats from '@/views/Stats.vue'
import Admin from '@/views/Admin.vue'
import Information from '@/views/Information.vue'
import MyTickets from '@/views/MyTickets.vue'
const routes = [
{
path: '/',
name: 'Home',
component: Home,
meta: { requiresAuth: true }
},
{
path: '/login',
name: 'Login',
component: Login,
meta: { layout: 'auth' }
},
{
path: '/register',
name: 'Register',
component: Register,
meta: { layout: 'auth' }
},
{
path: '/events',
name: 'Events',
component: Events,
meta: { requiresAuth: true }
},
{
path: '/events/:id',
name: 'EventDetail',
component: EventDetail,
meta: { requiresAuth: true }
},
{
path: '/albums',
name: 'Albums',
component: Albums,
meta: { requiresAuth: true }
},
{
path: '/albums/:id',
name: 'AlbumDetail',
component: AlbumDetail,
meta: { requiresAuth: true }
},
{
path: '/vlogs',
name: 'Vlogs',
component: Vlogs,
meta: { requiresAuth: true }
},
{
path: '/vlogs/:id',
name: 'VlogDetail',
component: VlogDetail,
meta: { requiresAuth: true }
},
{
path: '/posts',
name: 'Posts',
component: Posts,
meta: { requiresAuth: true }
},
{
path: '/profile',
name: 'Profile',
component: Profile,
meta: { requiresAuth: true }
},
{
path: '/profile/:id',
name: 'UserProfile',
component: UserProfile,
meta: { requiresAuth: true }
},
{
path: '/stats',
name: 'Stats',
component: Stats,
meta: { requiresAuth: true }
},
{
path: '/admin',
name: 'Admin',
component: Admin,
meta: { requiresAuth: true, requiresAdmin: true }
},
{
path: '/information',
name: 'Information',
component: Information,
meta: { requiresAuth: true }
},
{
path: '/my-tickets',
name: 'MyTickets',
component: MyTickets,
meta: { requiresAuth: true }
}
]
const router = createRouter({
history: createWebHistory(),
routes
})
// Navigation guard
router.beforeEach((to, from, next) => {
const authStore = useAuthStore()
if (to.meta.requiresAuth && !authStore.isAuthenticated) {
next('/login')
} else if (to.meta.requiresAdmin && !authStore.isAdmin) {
next('/')
} else if ((to.name === 'Login' || to.name === 'Register') && authStore.isAuthenticated) {
next('/')
} else {
next()
}
})
export default router