|
|
@@ -144,37 +144,37 @@ const Statistics: React.FC<StatisticsProps> = () => {
|
|
|
}
|
|
|
}, [])
|
|
|
|
|
|
- // 使用 Taro 页面级下拉刷新钩子
|
|
|
- Taro.usePullDownRefresh(async () => {
|
|
|
- await handleRefresh()
|
|
|
- })
|
|
|
-
|
|
|
// 下拉刷新处理函数:刷新所有统计数据
|
|
|
const handleRefresh = async () => {
|
|
|
- console.log('🔄 [下拉刷新] 开始刷新所有统计数据...')
|
|
|
+ console.log("🔄 [下拉刷新] 开始刷新所有统计数据...")
|
|
|
try {
|
|
|
- console.log('🔄 [下拉刷新] 开始执行 invalidateQueries Promise.all...')
|
|
|
+ console.log("🔄 [下拉刷新] 开始执行 invalidateQueries Promise.all...")
|
|
|
await Promise.all([
|
|
|
- queryClient.invalidateQueries({ queryKey: ['statistics', 'employment-count'] }),
|
|
|
- queryClient.invalidateQueries({ queryKey: ['statistics', 'average-salary'] }),
|
|
|
- queryClient.invalidateQueries({ queryKey: ['statistics', 'employment-rate'] }),
|
|
|
- queryClient.invalidateQueries({ queryKey: ['statistics', 'disability-type-distribution'] }),
|
|
|
- queryClient.invalidateQueries({ queryKey: ['statistics', 'gender-distribution'] }),
|
|
|
- queryClient.invalidateQueries({ queryKey: ['statistics', 'age-distribution'] }),
|
|
|
- queryClient.invalidateQueries({ queryKey: ['statistics', 'household-distribution'] }),
|
|
|
- queryClient.invalidateQueries({ queryKey: ['statistics', 'job-status-distribution'] }),
|
|
|
- queryClient.invalidateQueries({ queryKey: ['statistics', 'salary-distribution'] }),
|
|
|
+ queryClient.invalidateQueries({ queryKey: ["statistics", "employment-count"] }),
|
|
|
+ queryClient.invalidateQueries({ queryKey: ["statistics", "average-salary"] }),
|
|
|
+ queryClient.invalidateQueries({ queryKey: ["statistics", "employment-rate"] }),
|
|
|
+ queryClient.invalidateQueries({ queryKey: ["statistics", "disability-type-distribution"] }),
|
|
|
+ queryClient.invalidateQueries({ queryKey: ["statistics", "gender-distribution"] }),
|
|
|
+ queryClient.invalidateQueries({ queryKey: ["statistics", "age-distribution"] }),
|
|
|
+ queryClient.invalidateQueries({ queryKey: ["statistics", "household-distribution"] }),
|
|
|
+ queryClient.invalidateQueries({ queryKey: ["statistics", "job-status-distribution"] }),
|
|
|
+ queryClient.invalidateQueries({ queryKey: ["statistics", "salary-distribution"] }),
|
|
|
])
|
|
|
- console.log('🔄 [下拉刷新] invalidateQueries Promise.all 完成!')
|
|
|
+ console.log("🔄 [下拉刷新] invalidateQueries Promise.all 完成!")
|
|
|
} catch (error) {
|
|
|
- console.error('🔄 [下拉刷新] 发生错误:', error)
|
|
|
+ console.error("🔄 [下拉刷新] 发生错误:", error)
|
|
|
} finally {
|
|
|
- console.log('🔄 [下拉刷新] 结束刷新状态')
|
|
|
+ console.log("🔄 [下拉刷新] 结束刷新状态")
|
|
|
Taro.stopPullDownRefresh()
|
|
|
}
|
|
|
}
|
|
|
+ // 使用 Taro 页面级下拉刷新钩子(仅在非 H5 环境)
|
|
|
+ // H5 环境不支持 usePullDownRefresh,会导致 React.useContext 错误
|
|
|
+ const usePullDownRefreshSafe = process.env.TARO_ENV !== "h5" ? Taro.usePullDownRefresh : () => {}
|
|
|
+ usePullDownRefreshSafe(async () => {
|
|
|
+ await handleRefresh()
|
|
|
+ })
|
|
|
|
|
|
- // 获取在职人数统计(简化版:无查询参数)
|
|
|
const { data: employmentCountData, isLoading: isLoadingEmploymentCount } = useQuery({
|
|
|
queryKey: ['statistics', 'employment-count'],
|
|
|
queryFn: async () => {
|