mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-29 09:02:03 +00:00
fix(nuxt): hook called twice during navigation
This commit is contained in:
parent
162055d0d0
commit
d5cf708041
@ -41,7 +41,6 @@ export default defineComponent({
|
||||
const nuxtApp = useNuxtApp()
|
||||
const pageRef = ref()
|
||||
const forkRoute = inject(PageRouteSymbol, null)
|
||||
let previousPageKey: string | undefined | false
|
||||
|
||||
expose({ pageRef })
|
||||
|
||||
@ -97,10 +96,6 @@ export default defineComponent({
|
||||
}
|
||||
|
||||
const key = generateRouteKey(routeProps, props.pageKey)
|
||||
if (!nuxtApp.isHydrating && !hasChildrenRoutes(forkRoute, routeProps.route, routeProps.Component) && previousPageKey === key) {
|
||||
nuxtApp.callHook('page:loading:end')
|
||||
}
|
||||
previousPageKey = key
|
||||
|
||||
const hasTransition = !!(props.transition ?? routeProps.route.meta.pageTransition ?? defaultPageTransition)
|
||||
const transitionProps = hasTransition && _mergeTransitionProps([
|
||||
@ -161,10 +156,3 @@ function haveParentRoutesRendered (fork: RouteLocationNormalizedLoaded | null, n
|
||||
(c, i) => c.components?.default !== fork.matched[i]?.components?.default) ||
|
||||
(Component && generateRouteKey({ route: newRoute, Component }) !== generateRouteKey({ route: fork, Component }))
|
||||
}
|
||||
|
||||
function hasChildrenRoutes (fork: RouteLocationNormalizedLoaded | null, newRoute: RouteLocationNormalizedLoaded, Component?: VNode) {
|
||||
if (!fork) { return false }
|
||||
|
||||
const index = newRoute.matched.findIndex(m => m.components?.default === Component?.type)
|
||||
return index < newRoute.matched.length - 1
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user