Ver Fonte

✨ feat(order-management): 添加60秒自动刷新订单列表功能

- 使用React Query内置定时刷新功能
- 配置60秒自动刷新间隔
- 优化性能:只在页面可见时刷新
- 设置30秒数据过期时间确保数据及时性

🤖 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 há 2 semanas atrás
pai
commit
4760b4ae29

+ 5 - 2
packages/order-management-ui-mt/src/components/OrderManagement.tsx

@@ -110,7 +110,7 @@ export const OrderManagement = () => {
     defaultValues: {},
   });
 
-  // 数据查询
+  // 数据查询 - 60秒自动刷新
   const { data, isLoading, refetch } = useQuery({
     queryKey: ['orders', searchParams],
     queryFn: async () => {
@@ -134,7 +134,10 @@ export const OrderManagement = () => {
       });
       if (res.status !== 200) throw new Error('获取订单列表失败');
       return await res.json();
-    }
+    },
+    refetchInterval: 60000, // 60秒自动刷新
+    refetchIntervalInBackground: false, // 只在页面可见时刷新
+    staleTime: 30000, // 30秒后数据视为过期
   });
 
   // 处理搜索