This commit is contained in:
2026-06-28 18:12:00 +02:00
parent 5152ec0f7e
commit 7a593fc204
27 changed files with 413 additions and 100 deletions
+54 -27
View File
@@ -6,48 +6,75 @@
// Composables
import {createRouter, createWebHistory} from 'vue-router'
import Index from '@/pages/index.vue'
import {useAuthStore} from '@/stores/auth'
import AuthLayout from "@/layouts/AuthLayout.vue";
import AppLayout from "@/layouts/AppLayout.vue";
import AdminLayout from "@/layouts/AdminLayout.vue";
const router = createRouter({
history: createWebHistory(import.meta.env.BASE_URL),
routes: [
// ----------------- GROUPE AUTHENTIFICATION -----------------
{
path: '/login',
name: 'login',
component: () => import('@/pages/login.vue'),
},
{
path: '/join',
name: 'join',
component: () => import('@/pages/join.vue'),
},
{
path: '/',
component: Index,
},
{
// Cette regex capture soit un UUID, soit le mot "default"
path: '/server/:id(default|[0-9a-fA-F-]{36})',
name: 'server-dashboard',
component: () => import('@/pages/server/index.vue'),
props: true,
path: '/auth',
component: AuthLayout,
children: [
{
path: 'channel/:channelId',
name: 'server-channel',
component: () => import('@/pages/server/channel/index.vue'),
path: 'login',
name: 'login',
component: () => import('@/pages/auth/login.vue'),
},
{
path: 'join',
name: 'join',
component: () => import('@/pages/auth/join.vue'),
},
// Vous pouvez ajouter ici 'reset-password', etc.
],
},
// ----------------- GROUPE APPLICATION GÉNÉRALE -----------------
{
path: '/',
component: AppLayout,
children: [
{
path: '',
name: 'home',
component: () => import('@/pages/index.vue'),
},
{
path: 'server/:id(default|[0-9a-fA-F-]{36})',
name: 'server-dashboard',
component: () => import('@/pages/server/index.vue'),
props: true,
children: [
{
path: 'channel/:channelId',
name: 'server-channel',
component: () => import('@/pages/server/channel/index.vue'),
props: true,
},
],
},
],
},
// ----------------- GROUPE ADMINISTRATION -----------------
{
path: '/admin',
name: 'admin-dashboard',
component: () => import('@/pages/admin/dashboard.vue'),
meta: {requiresAdmin: true}
component: AdminLayout,
meta: {requiresAdmin: true},
children: [
{
path: '',
name: 'admin-dashboard',
component: () => import('@/pages/admin/dashboard.vue'),
},
// Ajoutez d'autres pages admin ici
],
},
],
})
@@ -64,7 +91,7 @@ router.beforeEach(async (to, from, next) => {
if (authRequired && !authStore.isAuthenticated) {
// Non connecté -> Login
next('/login')
next('/auth/login')
} else if (to.name === 'login' && authStore.isAuthenticated) {
// Déjà connecté -> Accueil
next('/')