mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-06-02 03:55:55 +00:00
47 lines
1.2 KiB
JavaScript
47 lines
1.2 KiB
JavaScript
|
|
/**
|
|
* router/index.ts
|
|
*
|
|
* Automatic routes for `./src/pages/*.vue`
|
|
*/
|
|
|
|
// Composables
|
|
import { createRouter, createWebHashHistory } from 'vue-router/auto'
|
|
import DashBoard from '../pages/DashBoard.vue'
|
|
import Settings from '../pages/Settings.vue'
|
|
import Logs from '../pages/Logs.vue'
|
|
import Plugins from '../pages/Plugins.vue'
|
|
|
|
const routes = [
|
|
{ path: '/', component: DashBoard },
|
|
{ path: '/settings', component: Settings },
|
|
{ path: '/logs', component: Logs },
|
|
{ path: '/plugins', component: Plugins },
|
|
]
|
|
|
|
const router = createRouter({
|
|
history: createWebHashHistory(),
|
|
routes,
|
|
})
|
|
|
|
// Workaround for https://github.com/vitejs/vite/issues/11804
|
|
router.onError((err, to) => {
|
|
if (err?.message?.includes?.('Failed to fetch dynamically imported module')) {
|
|
if (!localStorage.getItem('vuetify:dynamic-reload')) {
|
|
console.log('Reloading page to fix dynamic import error')
|
|
localStorage.setItem('vuetify:dynamic-reload', 'true')
|
|
location.assign(to.fullPath)
|
|
} else {
|
|
console.error('Dynamic import error, reloading page did not fix it', err)
|
|
}
|
|
} else {
|
|
console.error(err)
|
|
}
|
|
})
|
|
|
|
router.isReady().then(() => {
|
|
localStorage.removeItem('vuetify:dynamic-reload')
|
|
})
|
|
|
|
export default router
|