fix: 营养素详情页修复 API 空响应未走本地兜底的问题
- 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 <noreply@anthropic.com>
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user