mirror of
https://github.com/aljazceru/meshcore-web.git
synced 2025-12-19 09:04:21 +01:00
preload routes
This commit is contained in:
17
src/main.js
17
src/main.js
@@ -5,9 +5,7 @@ import "./style.css";
|
|||||||
|
|
||||||
import App from './components/App.vue';
|
import App from './components/App.vue';
|
||||||
|
|
||||||
const router = createRouter({
|
const routes = [
|
||||||
history: createMemoryHistory(),
|
|
||||||
routes: [
|
|
||||||
{
|
{
|
||||||
name: "main",
|
name: "main",
|
||||||
path: '/',
|
path: '/',
|
||||||
@@ -29,9 +27,20 @@ const router = createRouter({
|
|||||||
path: '/settings/radio',
|
path: '/settings/radio',
|
||||||
component: () => import("./components/pages/RadioSettingsPage.vue"),
|
component: () => import("./components/pages/RadioSettingsPage.vue"),
|
||||||
},
|
},
|
||||||
],
|
];
|
||||||
|
|
||||||
|
const router = createRouter({
|
||||||
|
history: createMemoryHistory(),
|
||||||
|
routes: routes,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// preload all route components, so they are available even if the server deploys a new version before the user navigates to a page
|
||||||
|
for(const route of routes){
|
||||||
|
if(typeof route.component === 'function'){
|
||||||
|
route.component();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
createApp(App)
|
createApp(App)
|
||||||
.use(router)
|
.use(router)
|
||||||
.use(vClickOutside)
|
.use(vClickOutside)
|
||||||
|
|||||||
Reference in New Issue
Block a user