优化详情返回首页停留

This commit is contained in:
yml2213
2026-07-11 23:25:51 +08:00
parent f81842d46e
commit 7614c0980e
4 changed files with 120 additions and 13 deletions
+9
View File
@@ -14,6 +14,15 @@ import { sellerRoutes } from './sellerRoutes'
const router = createRouter({
history: createWebHistory(),
routes: [...adminRoutes, ...mobileRoutes, ...publicRoutes, ...accountRoutes, ...sellerRoutes],
scrollBehavior(to, _from, savedPosition) {
// 浏览器前进/后退优先用历史滚动位置
if (savedPosition) return savedPosition
// 移动端首页由 KeepAlive + 组件内自行恢复滚动,避免被强制拉回顶部
if (to.name === 'mobile-home' || to.name === 'mobile-listings') {
return false
}
return { left: 0, top: 0 }
},
})
router.beforeEach(async to => {