perf(listings): 优化从详情页返回首页的滚动恢复体验,消除顶部闪跳

This commit is contained in:
yml2213
2026-09-07 10:12:41 +08:00
parent 23883d4be5
commit 41f70470ec
5 changed files with 228 additions and 43 deletions
@@ -368,13 +368,6 @@ function restoreScrollPosition() {
}
onMounted(() => {
const restoredList = restoreFromCache()
if (!restoredList) {
loadListings()
}
if (!restoreHomeConfigFromCache()) {
loadHomeConfig()
}
if (restoredList) {
restoreScrollPosition()
}
@@ -811,6 +804,15 @@ function getItemResourcePreview(item: Listing) {
}
syncMobileHomeQuery()
// 同步恢复列表和配置快照,确保首帧 DOM 即包含完整卡片列表,避免高度塌陷和滚动闪跳
const restoredList = restoreFromCache()
if (!restoredList) {
loadListings()
}
if (!restoreHomeConfigFromCache()) {
loadHomeConfig()
}
</script>
<template>