Initial commit

This commit is contained in:
2026-02-03 10:38:46 +01:00
commit eb304f4b14
144 changed files with 22605 additions and 0 deletions

60
admin/src/router/index.ts Normal file
View File

@@ -0,0 +1,60 @@
import { createRouter, createWebHistory } from 'vue-router'
import { useAuth } from '../composables/useAuth'
import AdminLayout from '../components/AdminLayout.vue'
const router = createRouter({
history: createWebHistory(),
routes: [
{
path: '/login',
name: 'login',
component: () => import('../pages/LoginPage.vue'),
meta: { public: true },
},
{
path: '/',
component: AdminLayout,
children: [
{
path: '',
name: 'events',
component: () => import('../pages/EventsListPage.vue'),
},
{
path: 'events/create',
name: 'event-create',
component: () => import('../pages/EventCreatePage.vue'),
},
{
path: 'events/:id/edit',
name: 'event-edit',
component: () => import('../pages/EventEditPage.vue'),
},
{
path: 'events/:id/uploads',
name: 'event-uploads',
component: () => import('../pages/EventUploadsPage.vue'),
},
],
},
],
})
router.beforeEach(async (to) => {
const { isAuthenticated, fetchUser } = useAuth()
if (to.name === 'login' && isAuthenticated.value) {
const redirect = (to.query.redirect as string) || '/'
return { path: redirect }
}
if (!to.meta.public) {
if (isAuthenticated.value) return true
try {
await fetchUser()
} catch {
return { name: 'login', query: { redirect: to.fullPath } }
}
}
return true
})
export default router