fix(export): 解决统计数据字段兼容性问题

- 添加对 snake_case 格式字段的兼容支持
- 使用空值合并运算符处理字段缺失情况
- 保持原有 camelCase 字段的向后兼容性
- 确保统计数据正确显示无论后端返回哪种命名格式
This commit is contained in:
2026-01-18 17:43:55 +08:00
parent 0c97648a9e
commit 3a3a28d5ea

View File

@@ -75,8 +75,9 @@ export default function ExportAnnotationDialog({
.then((res: any) => {
const data = res?.data || res;
setStats({
totalFiles: data?.totalFiles || 0,
annotatedFiles: data?.annotatedFiles || 0,
// 兼容 snake_case 和 camelCase
totalFiles: data?.totalFiles ?? data?.total_files ?? 0,
annotatedFiles: data?.annotatedFiles ?? data?.annotated_files ?? 0,
});
})
.catch((err) => {