From 133a7a78da9e40c53667b606dc6c537c7c904d04 Mon Sep 17 00:00:00 2001 From: lejunyang Date: Sun, 11 Aug 2024 21:27:37 +0800 Subject: [PATCH] feat(client): add `onAfterPageLoad` for router --- src/client/app/router.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/client/app/router.ts b/src/client/app/router.ts index 0e04703e..3c6fb4f7 100644 --- a/src/client/app/router.ts +++ b/src/client/app/router.ts @@ -29,6 +29,10 @@ export interface Router { * updated). Return `false` to cancel the navigation. */ onBeforePageLoad?: (to: string) => Awaitable + /** + * Called after the page component is loaded (before the page component is updated). + */ + onAfterPageLoad?: (to: string) => Awaitable /** * Called after the route changes. */ @@ -94,6 +98,8 @@ export function createRouter( throw new Error(`Invalid route component: ${comp}`) } + await router.onAfterPageLoad?.(href) + route.path = inBrowser ? pendingPath : withBase(pendingPath) route.component = markRaw(comp) route.data = import.meta.env.PROD