fix(nuxt): skip view transitions where there is no route change (#22140)

This commit is contained in:
Jianqi Pan 2023-07-14 22:49:57 +09:00 committed by GitHub
parent a07cfb8663
commit 988e75bbc7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -9,9 +9,10 @@ export default defineNuxtPlugin((nuxtApp) => {
const router = useRouter()
router.beforeResolve((to) => {
if (to.meta.pageTransition === false) { return }
router.beforeResolve((to, from) => {
if (to === from || to.matched.every((comp, index) => comp.components && comp.components?.default === from.matched[index]?.components?.default)) {
return
}
const promise = new Promise<void>((resolve, reject) => {
finishTransition = resolve
abortTransition = reject