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

@@ -144,7 +144,7 @@
<ShopOutlined/>
站点管理
</a-button>
<a-button block @click="$router.push('/website/order')">
<a-button block @click="$router.push('/shopOrder')">
<CalendarOutlined/>
订单管理
</a-button>
@@ -154,7 +154,11 @@
</a-button>
<a-button block @click="$router.push('/system/login-record')">
<FileTextOutlined/>
系统日志
登录日志
</a-button>
<a-button block @click="refreshStatistics" :loading="loading">
<ReloadOutlined/>
刷新统计
</a-button>
<a-button block @click="clearSiteInfoCache">
<ClearOutlined/>
@@ -183,7 +187,8 @@ import {
AccountBookOutlined,
FileTextOutlined,
ClearOutlined,
MoneyCollectOutlined
MoneyCollectOutlined,
ReloadOutlined
} from '@ant-design/icons-vue';
import {message} from 'ant-design-vue/es';
import {openNew} from "@/utils/common";
@@ -233,6 +238,17 @@ const clearSiteInfoCache = () => {
);
};
// 刷新统计数据
const refreshStatistics = async () => {
try {
await statisticsStore.forceRefresh();
message.success('统计数据刷新成功');
} catch (error) {
console.error('刷新统计数据失败:', error);
message.error('刷新统计数据失败');
}
};
onMounted(async () => {
// 加载网站信息和统计数据
try {