Browse Source

fix: 使用 invalidateQueries + refetchType:all 正确刷新所有查询

- refetchQueries 无法刷新 disabled (enabled: false) 的查询
- invalidateQueries + refetchType: 'all' 可以刷新包括 inactive 的查询
- 参考 TanStack Query v5 官方文档

Generated with [Claude Code](https://claude.ai/code)
via [Happy](https://happy.engineering)

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
yourname 1 day ago
parent
commit
503d2faf02

+ 4 - 3
mini-ui-packages/yongren-statistics-ui/src/pages/Statistics/Statistics.tsx

@@ -119,10 +119,11 @@ const Statistics: React.FC<StatisticsProps> = () => {
   // 下拉刷新:刷新所有统计数据
   // 下拉刷新:刷新所有统计数据
   usePullDownRefresh(async () => {
   usePullDownRefresh(async () => {
     try {
     try {
-      // refetchQueries + type: 'all' 强制刷新所有统计查询(包括 inactive 的懒加载图表)
-      await queryClient.refetchQueries({
+      // invalidateQueries + refetchType: 'all' 强制刷新所有查询(包括 inactive 的)
+      // refetchQueries 无法刷新 disabled (enabled: false) 的查询
+      await queryClient.invalidateQueries({
         queryKey: ['statistics'],
         queryKey: ['statistics'],
-        type: 'all'  // 刷新所有匹配的查询,包括 inactive 的
+        refetchType: 'all'  // 刷新所有匹配的查询,包括 inactive 的
       })
       })
     } finally {
     } finally {
       Taro.stopPullDownRefresh()
       Taro.stopPullDownRefresh()