2022-03-31 00:33:29 +02:00
|
|
|
import { createRouter, createWebHistory } from 'vue-router';
|
2022-08-04 22:46:50 +02:00
|
|
|
import { layouts } from './layouts/index';
|
2022-03-31 00:33:29 +02:00
|
|
|
import HomePage from './pages/Home.page.vue';
|
2022-04-05 17:40:35 +02:00
|
|
|
import NotFound from './pages/404.page.vue';
|
2022-03-31 00:33:29 +02:00
|
|
|
import { tools } from './tools';
|
2022-05-24 00:07:54 +02:00
|
|
|
import { config } from './config';
|
2023-04-23 22:26:32 +02:00
|
|
|
import { routes as demoRoutes } from './ui/demo/demo.routes';
|
2022-03-31 00:33:29 +02:00
|
|
|
|
2022-04-22 23:31:40 +02:00
|
|
|
const toolsRoutes = tools.map(({ path, name, component, ...config }) => ({
|
|
|
|
path,
|
|
|
|
name,
|
|
|
|
component,
|
|
|
|
meta: { isTool: true, layout: layouts.toolLayout, name, ...config },
|
|
|
|
}));
|
2022-04-16 10:10:21 +02:00
|
|
|
const toolsRedirectRoutes = tools
|
|
|
|
.filter(({ redirectFrom }) => redirectFrom && redirectFrom.length > 0)
|
2022-04-22 23:31:40 +02:00
|
|
|
.flatMap(
|
|
|
|
({ path, redirectFrom }) => redirectFrom?.map((redirectSource) => ({ path: redirectSource, redirect: path })) ?? [],
|
|
|
|
);
|
2022-04-16 10:10:21 +02:00
|
|
|
|
2022-03-31 00:33:29 +02:00
|
|
|
const router = createRouter({
|
2022-05-24 00:07:54 +02:00
|
|
|
history: createWebHistory(config.app.baseUrl),
|
2022-03-31 00:33:29 +02:00
|
|
|
routes: [
|
|
|
|
{
|
|
|
|
path: '/',
|
|
|
|
name: 'home',
|
|
|
|
component: HomePage,
|
|
|
|
},
|
2022-04-16 10:46:52 +02:00
|
|
|
{
|
|
|
|
path: '/about',
|
|
|
|
name: 'about',
|
|
|
|
component: () => import('./pages/About.vue'),
|
|
|
|
},
|
2022-04-16 10:10:21 +02:00
|
|
|
...toolsRoutes,
|
|
|
|
...toolsRedirectRoutes,
|
2023-04-23 22:26:32 +02:00
|
|
|
...(config.app.env === 'development' ? demoRoutes : []),
|
2022-04-05 17:40:35 +02:00
|
|
|
{ path: '/:pathMatch(.*)*', name: 'NotFound', component: NotFound },
|
2022-03-31 00:33:29 +02:00
|
|
|
],
|
|
|
|
});
|
|
|
|
|
|
|
|
export default router;
|