From 64de7d055b9b44e6317223a3ac51d718b0cbd689 Mon Sep 17 00:00:00 2001 From: zdl <3489966805@qq.com> Date: Wed, 5 Nov 2025 09:35:35 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E6=A8=A1=E5=BC=8F?= =?UTF-8?q?=E5=88=87=E6=8D=A2=E6=97=B6=E4=B8=A2=E5=A4=B1=E7=AD=9B=E9=80=89?= =?UTF-8?q?=E6=9D=A1=E4=BB=B6=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 问题描述: - 用户在单排/双排/纵向模式下应用筛选条件后,切换到平铺模式时筛选条件丢失 - usePagination hook 在模式切换时重新请求数据,但未传递筛选参数 修复内容: 1. usePagination.js - 新增 filters 参数接收筛选条件 - handleModeToggle 函数在发起请求时应用 ...filters - 将 filters 添加到依赖数组,确保筛选条件变化时重新执行 2. DynamicNewsCard.js - 将 filters 传递给 usePagination hook - 确保筛选条件在模式切换时保持一致 影响范围: - 所有展示模式切换(单排、双排、纵向、平铺) 测试建议: 1. 应用任意筛选条件(如排序、重要性、关键词) 2. 切换到平铺模式 3. 验证筛选条件是否保持生效 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- src/views/Community/components/DynamicNewsCard.js | 3 ++- .../components/DynamicNewsCard/hooks/usePagination.js | 8 +++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/views/Community/components/DynamicNewsCard.js b/src/views/Community/components/DynamicNewsCard.js index 0f30e277..c59e0078 100644 --- a/src/views/Community/components/DynamicNewsCard.js +++ b/src/views/Community/components/DynamicNewsCard.js @@ -113,7 +113,8 @@ const DynamicNewsCard = forwardRef(({ total, cachedCount, dispatch, - toast + toast, + filters // 传递筛选条件 }); // 四排模式的事件点击处理(打开弹窗) diff --git a/src/views/Community/components/DynamicNewsCard/hooks/usePagination.js b/src/views/Community/components/DynamicNewsCard/hooks/usePagination.js index 11426d98..7c734a6d 100644 --- a/src/views/Community/components/DynamicNewsCard/hooks/usePagination.js +++ b/src/views/Community/components/DynamicNewsCard/hooks/usePagination.js @@ -19,9 +19,10 @@ import { * @param {number} options.cachedCount - 已缓存数量 * @param {Function} options.dispatch - Redux dispatch 函数 * @param {Function} options.toast - Toast 通知函数 + * @param {Object} options.filters - 筛选条件 * @returns {Object} 分页状态和方法 */ -export const usePagination = ({ allCachedEvents, total, cachedCount, dispatch, toast }) => { +export const usePagination = ({ allCachedEvents, total, cachedCount, dispatch, toast, filters = {} }) => { // 本地状态 const [currentPage, setCurrentPage] = useState(PAGINATION_CONFIG.INITIAL_PAGE); const [loadingPage, setLoadingPage] = useState(null); @@ -314,11 +315,12 @@ export const usePagination = ({ allCachedEvents, total, cachedCount, dispatch, t page: 1, per_page: newPageSize, pageSize: newPageSize, // 传递 pageSize 确保索引计算一致 - clearCache: true + clearCache: true, + ...filters // 应用筛选条件 })); } // 如果第1页数据完整,不发起请求,直接切换 - }, [mode, allCachedEvents, total, dispatch]); + }, [mode, allCachedEvents, total, dispatch, filters]); return { // 状态