fix: 软刷新齐套前保留旧画面,避免一点击就卸光

Logo/下拉静默预热后一次覆盖;commit 不再先 reset/loading;顺带会话预取与可配置 Feed 排序标签。
This commit is contained in:
2026-09-01 04:56:10 +08:00
parent ba60a9b1c4
commit 9e134916a4
47 changed files with 2446 additions and 636 deletions

View File

@@ -0,0 +1,20 @@
import { prefetchLayoutShell, prefetchRoute } from './prefetchRoute';
/** 软刷新齐套后的单一提交:各组件同一拍从 cache/快照同步 UI禁止分批闪烁 */
export const PAGE_SOFT_REFRESH_COMMIT_EVENT = 'page-soft-refresh-commit';
/**
* 静默刷新当前页:不改画面、无进度条,预热齐套后派发一次 commit。
*/
export async function softRefreshCurrentPage(to?: string): Promise<void> {
const path = to ?? `${window.location.pathname}${window.location.search}`;
try {
await Promise.all([
prefetchRoute(path, { force: true }),
prefetchLayoutShell({ force: true }),
]);
} catch {
// 仍派发 commit让界面有机会用已有缓存自愈
}
window.dispatchEvent(new Event(PAGE_SOFT_REFRESH_COMMIT_EVENT));
}