chore: update pom.xml Lombok config and deploy settings
- Update Maven compiler plugin to support Lombok annotation processing - Add deploy.conf for automated deployment - Update backend models and controllers - Update frontend pages and API
This commit is contained in:
@@ -134,8 +134,9 @@ export default {
|
||||
},
|
||||
onLoad(options) {
|
||||
this.pageParams = { id: options.id || '', name: options.name || '' }
|
||||
// 打印入参便于排查:后端详情接口仅接受 Long 类型 id
|
||||
console.log('[food-detail] onLoad params:', this.pageParams)
|
||||
// 打印入参便于排查:后端详情接口仅接受 Long 类型 id,传 name 会导致 400
|
||||
console.log('[food-detail] onLoad options:', options)
|
||||
console.log('[food-detail] onLoad pageParams (id/name):', this.pageParams)
|
||||
const rawId = options.id
|
||||
const isNumericId = rawId !== undefined && rawId !== '' && !isNaN(Number(rawId))
|
||||
if (isNumericId) {
|
||||
@@ -144,7 +145,9 @@ export default {
|
||||
// 无有效 id 仅有 name 时,不请求接口(避免传 name 导致后端 NumberFormatException),直接展示默认数据 + 当前名称
|
||||
this.loadError = '暂无该食物详情数据,展示参考数据'
|
||||
this.applyDefaultFoodData(false)
|
||||
this.foodData.name = decodeURIComponent(String(options.name))
|
||||
try {
|
||||
this.foodData.name = decodeURIComponent(String(options.name))
|
||||
} catch (e) {}
|
||||
} else {
|
||||
this.applyDefaultFoodData()
|
||||
}
|
||||
@@ -164,14 +167,17 @@ export default {
|
||||
/** 用 defaultFoodData 填充页面,保证 keyNutrients/nutritionTable 为非空数组以便 .nutrient-card / .nutrition-row 正常渲染;clearError 为 true 时顺带清空 loadError */
|
||||
applyDefaultFoodData(clearError = true) {
|
||||
if (clearError) this.loadError = ''
|
||||
const def = this.defaultFoodData
|
||||
const fallbackKey = (def.keyNutrients && def.keyNutrients.length) ? def.keyNutrients : [{ name: '—', value: '—', unit: '', status: '—' }]
|
||||
const fallbackTable = (def.nutritionTable && def.nutritionTable.length) ? def.nutritionTable : [{ name: '—', value: '—', unit: '', level: 'low', levelText: '—' }]
|
||||
this.foodData = {
|
||||
...this.defaultFoodData,
|
||||
name: this.defaultFoodData.name || '—',
|
||||
category: this.defaultFoodData.category || '—',
|
||||
safetyTag: this.defaultFoodData.safetyTag || '—',
|
||||
image: this.defaultFoodData.image || '',
|
||||
keyNutrients: [...(this.defaultFoodData.keyNutrients || [])],
|
||||
nutritionTable: [...(this.defaultFoodData.nutritionTable || [])]
|
||||
...def,
|
||||
name: (def && def.name) ? def.name : '—',
|
||||
category: (def && def.category) ? def.category : '—',
|
||||
safetyTag: (def && def.safetyTag) ? def.safetyTag : '—',
|
||||
image: (def && def.image) ? def.image : '',
|
||||
keyNutrients: Array.isArray(def.keyNutrients) && def.keyNutrients.length > 0 ? [...def.keyNutrients] : [...fallbackKey],
|
||||
nutritionTable: Array.isArray(def.nutritionTable) && def.nutritionTable.length > 0 ? [...def.nutritionTable] : [...fallbackTable]
|
||||
}
|
||||
},
|
||||
/** 保证数组非空,空时返回 fallback 的副本,用于 API 解析结果避免空数组导致列表不渲染 */
|
||||
@@ -199,11 +205,20 @@ export default {
|
||||
nutritionTable: this.ensureNonEmptyArray(this.parseNutritionTable(data), this.defaultFoodData.nutritionTable)
|
||||
}
|
||||
} else {
|
||||
// API 返回空数据,使用默认数据
|
||||
this.applyDefaultFoodData()
|
||||
// API 返回空数据,按“失败”处理:展示默认数据 + 缓存提示
|
||||
const emptyMsg = (data == null || !data.name) ? '接口返回数据为空' : '缺少食物名称'
|
||||
console.warn('[food-detail] 接口返回无效数据:', data)
|
||||
this.loadError = emptyMsg
|
||||
this.applyDefaultFoodData(false)
|
||||
if (this.pageParams && this.pageParams.name) {
|
||||
try {
|
||||
this.foodData.name = decodeURIComponent(String(this.pageParams.name))
|
||||
} catch (e) {}
|
||||
}
|
||||
uni.showToast({ title: '数据加载失败', icon: 'none' })
|
||||
}
|
||||
} catch (error) {
|
||||
const errMsg = (error && (error.message || error.msg || error)) ? String(error.message || error.msg || error) : '未知错误'
|
||||
const errMsg = (error && (error.message || error.msg || error.errMsg || error)) ? String(error.message || error.msg || error.errMsg || error) : '未知错误'
|
||||
console.error('[food-detail] 加载食物数据失败:', error)
|
||||
// a. 将 loadError 置为具体错误信息(用于调试)
|
||||
this.loadError = errMsg
|
||||
|
||||
Reference in New Issue
Block a user