Files
sasiedzi/src/main/webapp/app/router/index.ts
T
2024-11-25 23:09:45 +01:00

52 lines
1.3 KiB
TypeScript

import { createRouter as createVueRouter, createWebHistory } from 'vue-router';
const Home = () => import('@/core/home/home.vue');
const Error = () => import('@/core/error/error.vue');
import admin from '@/router/admin';
import entities from '@/router/entities';
import pages from '@/router/pages';
import { Authority } from '@/shared/security/authority';
const EventDetails = () => import('@/entities/event/event-details.vue');
const Event = () => import('@/entities/event/event.vue');
export const createRouter = () =>
createVueRouter({
history: createWebHistory(),
routes: [
{
path: '/',
name: 'CurrentEventView',
component: EventDetails,
meta: { authorities: [Authority.USER], eventId: '2601' },
},
{
path: '/forbidden',
name: 'Forbidden',
component: Error,
meta: { error403: true },
},
{
path: '/not-found',
redirect: '/',
// name: 'NotFound',
// component: Error,
// meta: { error404: true },
},
...admin,
entities,
...pages,
],
});
const router = createRouter();
router.beforeResolve(async (to, from, next) => {
if (!to.matched.length) {
next({ path: '/not-found' });
return;
}
next();
});
export default router;