fix: 修复6项测试问题并补全配套资源
- 修复油脂类食物推荐量系数 (5.7→2.5) [ToolCalculatorServiceImpl] - AI营养师接入真实Coze API,替换Mock回复 [ToolAiNutritionistServiceImpl] - 食物百科详情新增钙/铁/维C/嘌呤/重量基准字段返回 [ToolFoodServiceImpl] - V2Food模型新增purine、servingSize字段 [V2Food.java] - 食物百科详情页动态重量标注+新增4项营养展示+替换Figma URL [food-detail.vue] - 修复营养素列表dataset传参Bug(WeChat camelCase) [nutrition-knowledge.vue] - 营养素详情页接入后端API+兜底本地数据+替换Figma URL [nutrient-detail.vue] - 新增数据库迁移脚本及参考初始化数据 [docs/sql/] - 新增前端占位图标5个 [static/images/] - 新增开发任务完成报告 [docs/] Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -108,40 +108,34 @@ export default {
|
||||
data() {
|
||||
return {
|
||||
// 图标资源
|
||||
iconWhyImportant: 'https://www.figma.com/api/mcp/asset/51e00c9b-5719-4391-9dff-68b70d24aece',
|
||||
iconRecommendation: 'https://www.figma.com/api/mcp/asset/29e03ae9-a3ba-4416-8c6e-962bf3a8c8bb',
|
||||
iconSuggestions: 'https://www.figma.com/api/mcp/asset/9027fced-f029-4f65-bba1-a0b5883b8d2b',
|
||||
nutrientData: {
|
||||
name: '钠',
|
||||
english: 'Sodium (Na)',
|
||||
icon: '🧂',
|
||||
description: '调节体液平衡的电解质',
|
||||
status: '适量控制',
|
||||
statusDesc: '可适量补充,保持均衡',
|
||||
importance: '钠参与调节体液平衡和血压,过多摄入会导致水肿和高血压,增加心血管负担。',
|
||||
recommendation: 'CKD患者:2-3g食盐/天(相当于800-1200mg钠)',
|
||||
foodSources: ['食盐', '酱油', '腌制食品', '加工肉类', '咸菜', '味精'],
|
||||
riskWarning: '摄入过多会导致水肿、高血压、心力衰竭等问题。',
|
||||
suggestions: [
|
||||
'每日食盐控制在3-5g(约一啤酒瓶盖)',
|
||||
'避免腌制、熏制食品',
|
||||
'少用酱油、味精等调味品',
|
||||
'可用葱姜蒜、柠檬汁调味',
|
||||
'查看食品标签,选择低钠产品',
|
||||
'透析患者控制饮水量'
|
||||
],
|
||||
disclaimer: '以上建议仅供参考,\n\r 具体方案请咨询您的医生或营养师'
|
||||
}
|
||||
iconWhyImportant: '/static/images/icon-why-important.png',
|
||||
iconRecommendation: '/static/images/icon-recommendation.png',
|
||||
iconSuggestions: '/static/images/icon-suggestions.png',
|
||||
nutrientName: '',
|
||||
nutrientData: {}
|
||||
}
|
||||
},
|
||||
onLoad(options) {
|
||||
// 根据传入的营养素名称加载对应数据
|
||||
if (options.name) {
|
||||
this.loadNutrientData(options.name)
|
||||
this.nutrientName = decodeURIComponent(options.name)
|
||||
this.loadNutrientData(this.nutrientName)
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
loadNutrientData(name) {
|
||||
async loadNutrientData(name) {
|
||||
// 优先调用后端接口获取营养素详情
|
||||
try {
|
||||
const { getNutrientDetail } = await import('@/api/tool.js')
|
||||
const res = await getNutrientDetail(name)
|
||||
if (res && res.data) {
|
||||
this.nutrientData = res.data
|
||||
return
|
||||
}
|
||||
} catch (e) {
|
||||
console.warn('API获取营养素详情失败,使用本地数据', e)
|
||||
}
|
||||
// 兜底:使用本地 nutrientMap
|
||||
const nutrientMap = {
|
||||
'钠': {
|
||||
name: '钠',
|
||||
@@ -271,9 +265,7 @@ export default {
|
||||
}
|
||||
}
|
||||
|
||||
if (nutrientMap[name]) {
|
||||
this.nutrientData = nutrientMap[name]
|
||||
}
|
||||
this.nutrientData = nutrientMap[name] || {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user