From 24f75d198c43796e601d8d50552cd0ccde075807 Mon Sep 17 00:00:00 2001 From: Developer Date: Wed, 25 Mar 2026 15:14:14 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=90=A5=E5=85=BB=E7=B4=A0=E8=AF=A6?= =?UTF-8?q?=E6=83=85=E9=A1=B5=E4=BF=AE=E5=A4=8D=20API=20=E7=A9=BA=E5=93=8D?= =?UTF-8?q?=E5=BA=94=E6=9C=AA=E8=B5=B0=E6=9C=AC=E5=9C=B0=E5=85=9C=E5=BA=95?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - loadNutrientData() 判断由 if(res.data) 改为 if(res.data && Object.keys(res.data).length > 0 && res.data.name) - 当后端 v2_knowledge 表无该营养素记录时(返回{}) 自动降级到本地 nutrientMap 展示内置数据 - 不影响正常有数据时的 API 优先逻辑 Co-Authored-By: Claude Sonnet 4.6 --- msh_single_uniapp/pages/tool/nutrient-detail.vue | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/msh_single_uniapp/pages/tool/nutrient-detail.vue b/msh_single_uniapp/pages/tool/nutrient-detail.vue index b9a3c49..88e7401 100644 --- a/msh_single_uniapp/pages/tool/nutrient-detail.vue +++ b/msh_single_uniapp/pages/tool/nutrient-detail.vue @@ -128,7 +128,8 @@ export default { try { const { getNutrientDetail } = await import('@/api/tool.js') const res = await getNutrientDetail(name) - if (res && res.data) { + // 后端返回空对象 {} 时不视为有效数据,继续走本地兜底 + if (res && res.data && typeof res.data === 'object' && Object.keys(res.data).length > 0 && res.data.name) { this.nutrientData = res.data return }