Просмотр исходного кода

fix: 使用 refetchQueries + type:all 强制触发所有统计接口

- invalidateQueries 只标记过期,不立即触发请求
- refetchQueries + type: 'all' 强制刷新所有查询(包括 inactive 的)
- 移除固定延迟,使用 Promise 等待真正请求完成

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 2 дней назад
Родитель
Сommit
9d720fb049

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

@@ -119,10 +119,11 @@ const Statistics: React.FC<StatisticsProps> = () => {
   // 下拉刷新:刷新所有统计数据
   usePullDownRefresh(async () => {
     try {
-      // invalidateQueries 标记所有统计查询为过期,触发重新请求
-      await queryClient.invalidateQueries({ queryKey: ['statistics'] })
-      // 等待请求完成(统计数据有9个API,需要一定时间)
-      await new Promise(resolve => setTimeout(resolve, 1500))
+      // refetchQueries + type: 'all' 强制刷新所有统计查询(包括 inactive 的懒加载图表)
+      await queryClient.refetchQueries({
+        queryKey: ['statistics'],
+        type: 'all'  // 刷新所有匹配的查询,包括 inactive 的
+      })
     } finally {
       Taro.stopPullDownRefresh()
     }