update pay ui
This commit is contained in:
@@ -372,27 +372,31 @@ const [currentMode, setCurrentMode] = useState('vertical');
|
|||||||
onModalOpen();
|
onModalOpen();
|
||||||
}, [onModalOpen, trackingFunctions]);
|
}, [onModalOpen, trackingFunctions]);
|
||||||
|
|
||||||
// 初始加载 - 只在组件首次挂载且对应模式数据为空时执行
|
// 初始加载 - 组件挂载时始终获取最新数据
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
// 添加防抖:如果已经初始化,不再执行
|
// 添加防抖:如果已经初始化,不再执行
|
||||||
if (hasInitialized.current) return;
|
if (hasInitialized.current) return;
|
||||||
|
|
||||||
const isDataEmpty = currentMode === 'vertical'
|
// ⚡ 始终获取最新数据,确保用户每次进入页面看到最新事件
|
||||||
? Object.keys(allCachedEventsByPage || {}).length === 0
|
hasInitialized.current = true;
|
||||||
: (allCachedEvents?.length || 0) === 0;
|
console.log('%c🚀 [初始加载] 获取最新事件数据', 'color: #10B981; font-weight: bold;', { mode, pageSize });
|
||||||
|
dispatch(fetchDynamicNews({
|
||||||
|
mode: mode, // 传递当前模式
|
||||||
|
per_page: pageSize,
|
||||||
|
pageSize: pageSize, // 传递 pageSize 确保索引计算一致
|
||||||
|
clearCache: true,
|
||||||
|
...filters, // 先展开筛选条件
|
||||||
|
page: PAGINATION_CONFIG.INITIAL_PAGE, // 然后覆盖 page 参数
|
||||||
|
}));
|
||||||
|
|
||||||
if (isDataEmpty) {
|
// ⚡ 组件卸载时重置初始化标记,确保下次进入页面会重新获取数据
|
||||||
hasInitialized.current = true;
|
return () => {
|
||||||
dispatch(fetchDynamicNews({
|
hasInitialized.current = false;
|
||||||
mode: mode, // 传递当前模式
|
isFirstRenderForFilters.current = true;
|
||||||
per_page: pageSize,
|
hasAutoSelectedFirstEvent.current = false;
|
||||||
pageSize: pageSize, // 传递 pageSize 确保索引计算一致
|
console.log('%c🧹 [卸载] 重置初始化标记', 'color: #F59E0B; font-weight: bold;');
|
||||||
clearCache: true,
|
};
|
||||||
...filters, // 先展开筛选条件
|
}, [dispatch, mode, pageSize]); // 移除 currentMode 依赖,避免模式切换时重复请求
|
||||||
page: PAGINATION_CONFIG.INITIAL_PAGE, // 然后覆盖 page 参数
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
}, [dispatch, currentMode, mode, pageSize]); // 移除 allCachedEventsByPage, allCachedEvents 依赖,避免数据更新触发重复请求
|
|
||||||
|
|
||||||
// 监听筛选条件变化 - 清空缓存并重新请求数据
|
// 监听筛选条件变化 - 清空缓存并重新请求数据
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|||||||
Reference in New Issue
Block a user