diff --git a/package.json b/package.json index 3b83310..dbc9e17 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "kodama-ui", - "version": "0.35.3", + "version": "0.37.0", "description": "Kodama UI is a Vue 3 component library that provides a set of components & funcionality to build your application.", "homepage": "https://50l3r.github.io/kodama-ui", "keywords": [ diff --git a/src/config/_router.ts b/src/config/_router.ts index 478ed49..eff85d6 100644 --- a/src/config/_router.ts +++ b/src/config/_router.ts @@ -3,13 +3,16 @@ import { createRouter, createWebHashHistory, RouteRecordRaw, - NavigationGuardWithThis + NavigationGuardWithThis, + createWebHistory } from 'vue-router' export default ( app: App, frontendRoutes: Array, - beforeEach?: NavigationGuardWithThis + beforeEach?: NavigationGuardWithThis, + historyMode: 'hash' | 'web' = 'hash', + on404 = '/404' ) => { const systemRoutes = [ { @@ -92,15 +95,21 @@ export default ( title: 'Error interno', public: true } - }, - { - path: '/:pathMatch(.*)*', - redirect: '/404' } ] + if (on404) { + routes.push({ + path: '/:pathMatch(.*)*', + redirect: on404 + }) + } + const router = createRouter({ - history: createWebHashHistory(), + history: + historyMode === 'hash' + ? createWebHashHistory() + : createWebHistory(), routes }) diff --git a/src/config/index.ts b/src/config/index.ts index 0ea114f..594fea6 100644 --- a/src/config/index.ts +++ b/src/config/index.ts @@ -19,6 +19,8 @@ export type KodamaParams = { router: { routes: Array beforeEach?: NavigationGuardWithThis + mode?: 'hash' | 'web' + route404?: string } components: Record menu: () => Menu[] @@ -62,7 +64,13 @@ export function init(params: KodamaParams, app?: App) { ) // App Routes - router(app, params.router.routes, params.router.beforeEach) + router( + app, + params.router.routes, + params.router.beforeEach, + params.router.mode, + params.router.route404 + ) // App Components components(app, params.components)