From bd3b6de9cd4c764078b99ddb13b7bdfa7cc7e1f4 Mon Sep 17 00:00:00 2001 From: Wenyan Date: Wed, 26 Nov 2025 10:23:01 +0800 Subject: [PATCH] =?UTF-8?q?debug(evaluation-groups):=20=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=20getEvaluationPointGroups=20=E8=B0=83=E8=AF=95=E6=97=A5?= =?UTF-8?q?=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## 修改内容 在 getEvaluationPointGroups 函数中添加详细的调试日志,用于排查数据获取问题: ### 新增调试日志 - 📦 打印完整 API 响应 - 📊 打印 response.data 和 response.data.data - ❌ 错误日志增强 - ✅ 转换成功后打印结果 ### 日志输出点 1. API 响应完整数据 2. response.data 检查 3. response.data.data 存在性验证 4. 数据转换后的 ruleGroups 5. 错误捕获和详细错误信息 ### 目的 帮助诊断以下问题: - 后端返回数据格式是否正确 - response.data.data 是否存在 - 数据转换是否成功 - 前端为什么没有显示数据 ### 文件 - app/api/evaluation_points/rule-groups.ts:1207-1225 ⚠️ 注意:这是临时调试日志,问题解决后应该移除或注释掉 --- app/api/evaluation_points/rule-groups.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/app/api/evaluation_points/rule-groups.ts b/app/api/evaluation_points/rule-groups.ts index 057cb0e..b243be9 100644 --- a/app/api/evaluation_points/rule-groups.ts +++ b/app/api/evaluation_points/rule-groups.ts @@ -1204,12 +1204,25 @@ export async function getEvaluationPointGroups( headers: token ? { 'Authorization': `Bearer ${token}` } : {} }); + // 🔍 调试:打印完整响应 + console.log('📦 getEvaluationPointGroups 完整响应:', JSON.stringify(response, null, 2)); + if (response.error) { + console.error('❌ getEvaluationPointGroups 错误:', response.error); return { error: response.error, status: response.status }; } if (response.data) { + console.log('📊 response.data:', response.data); + console.log('📊 response.data.data:', response.data.data); + + if (!response.data.data) { + console.error('❌ response.data.data 不存在!完整 response.data:', response.data); + return { error: '返回数据格式不正确:缺少 data 字段', status: 500 }; + } + const ruleGroups = response.data.data.map(convertApiGroupToRuleGroup); + console.log('✅ 转换后的 ruleGroups:', ruleGroups); return { data: ruleGroups, totalCount: response.data.total