refactor(statistics): 重构统计数据获取逻辑

- 使用 Promise.allSettled 替代 Promise.all,提高容错性
- 添加详细的错误处理和日志记录,便于调试
- 优化用户、订单和销售额的计算逻辑,提高数据准确性
- 移除无效的 API 调用和冗余代码,简化代码结构
- 在 dashboard 页面添加刷新统计按钮,实现统计数据的强制刷新功能
This commit is contained in:
2025-09-07 13:18:09 +08:00
parent a0375d8a97
commit 7b6fac7c41
4 changed files with 142 additions and 78 deletions

View File

@@ -129,8 +129,9 @@ export async function shopOrderTotal(params?: ShopOrderParam) {
params
}
);
if (res.data.code === 0 && res.data.data) {
return res.data.data;
if (res.data.code === 0) {
// 即使没有数据也返回空数组,而不是抛出错误
return res.data.data || [];
}
return Promise.reject(new Error(res.data.message));
}