cvgen/src/router.ts

79 lines
1.5 KiB
TypeScript

// eslint-disable-next-line no-unused-vars
import { createRouter, createWebHistory, RouteRecordRaw } from 'vue-router'
// import { defineAsyncComponent } from 'vue'
import generatedRoutes from 'virtual:generated-pages'
import {has_config} from '~/hooks/config'
import {load_data_info} from '~/hooks/loads'
import Home from '~/views/Home.vue'
// import About from '~/views/about.md'
const check_config = async(to: any, _from: any, next: any) => {
if (await has_config()) {
next()
} else {
next('/noconfig')
}
}
const routes: RouteRecordRaw[] = [
{
path: '/',
name: 'Home',
component: Home,
meta: {
requireAuth: false,
layout: 'AppLayout',
withauth: false,
},
beforeEnter: [check_config, load_data_info ]
},
{
path: '/cv',
name: 'cv',
component: Home,
meta: {
requireAuth: false,
layout: 'AppLayout',
withauth: false,
},
beforeEnter: [check_config, load_data_info ]
},
{
path: '/cv/:ky',
name: 'cvKey',
component: Home,
meta: {
requireAuth: false,
layout: 'AppLayout',
withauth: false,
},
beforeEnter: [check_config, load_data_info ]
},
{
path: '/:ky',
name: 'HomeKey',
component: Home,
meta: {
requireAuth: false,
layout: 'AppLayout',
withauth: false,
},
beforeEnter: [check_config, load_data_info ]
},
{
path: '/:catchAll(.*)',
name: '404',
meta: { layout: 'Page404' },
component: () => import('./views/404.vue'),
},
...generatedRoutes,
]
const router: any = createRouter({
history: createWebHistory(),
routes,
})
export default router