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