Skip to content

Commit

Permalink
perf: lazyload components in router
Browse files Browse the repository at this point in the history
  • Loading branch information
StarHeartHunt committed Dec 25, 2023
1 parent 4903607 commit f14c722
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions src/router.ts
Original file line number Diff line number Diff line change
@@ -1,27 +1,23 @@
import { createRouter, createWebHistory } from "vue-router";

import Home from "@/views/Home.vue";
import NotFound from "@/views/NotFound.vue";
import PluginPage from "@/views/PluginPage.vue";

const routes = [
{
path: "/",
component: Home,
component: () => import("@/views/Home.vue"),
},
{
path: "/search",
component: Home,
component: () => import("@/views/Home.vue"),
props: (route: { query: { q: string } }) => ({ query: route.query.q }),
},
{
path: "/plugin/:path",
component: PluginPage,
component: () => import("@/views/PluginPage.vue"),
props: true,
},
{
path: "/:pathMatched(.*)*",
component: NotFound,
component: () => import("@/views/NotFound.vue"),
props: (route: { params: { pathMatched: string } }) => ({
pathMatched: `/${route.params.pathMatched}`,
}),
Expand Down

0 comments on commit f14c722

Please sign in to comment.