fix: 用 Zustand 缓存 Feed 列表,返回时恢复滚动且不重复请求
点击 Logo 仍强制刷新;后退忽略 history 上的 refreshFeed,并支持过期静默刷新与下拉刷新。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { useEffect, useRef, useState } from 'react';
|
||||
import { Loader2, ArrowDown } from 'lucide-react';
|
||||
import { FEED_PULL_REFRESH_EVENT } from '../utils/feedCache';
|
||||
|
||||
/** 触发刷新的下拉距离(px) */
|
||||
const REFRESH_THRESHOLD = 68;
|
||||
@@ -167,6 +168,18 @@ export default function PullToRefresh() {
|
||||
setSettling(true);
|
||||
setPull(REFRESH_THRESHOLD * 0.7);
|
||||
window.setTimeout(() => {
|
||||
// Feed 页:应用内强制重拉(保留 SPA 其它状态);其它页仍整页 reload
|
||||
const isFeed = !!(
|
||||
document.querySelector('.main-content--feed-mobile-scroll')
|
||||
|| document.querySelector('.page-wrap--feed .post-list-scroll')
|
||||
);
|
||||
if (isFeed) {
|
||||
window.dispatchEvent(new Event(FEED_PULL_REFRESH_EVENT));
|
||||
setRefreshing(false);
|
||||
setSettling(true);
|
||||
setPull(0);
|
||||
return;
|
||||
}
|
||||
window.location.reload();
|
||||
}, 180);
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user