feat(theme): improve page scroll behavior (#557)

This commit is contained in:
pengzhanbo 2025-04-15 21:27:06 +08:00 committed by GitHub
parent a0de3c660a
commit eef222086f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -13,15 +13,18 @@ export function enhanceScrollBehavior(router: Router) {
return { top: 0 }
}
router.beforeEach(() => {
router.beforeEach((to, from) => {
if (inBrowser) {
document.documentElement.classList.remove('smooth')
if (from.path !== to.path)
document.documentElement.classList.remove('smooth')
}
})
router.afterEach(() => nextTick(() => {
if (inBrowser) {
document.documentElement.classList.add('smooth')
setTimeout(() => {
document.documentElement.classList.add('smooth')
}, 1000)
}
}))
}