feat: 更新前端多个页面和后端服务

- 前端: 更新AI营养师、计算器、打卡、食物详情等页面
- 前端: 更新食物百科、知识详情、营养知识页面
- 前端: 更新社区首页
- 后端: 更新ToolKieAIServiceImpl服务
- API: 更新models-api.js和user.js
This commit is contained in:
2026-03-07 22:26:37 +08:00
parent 1632801880
commit f692c75f7b
11 changed files with 221 additions and 85 deletions

View File

@@ -241,17 +241,20 @@ export default {
return;
}
try {
const { setSignIntegral, getUserInfo } = await import('@/api/user.js');
const { setSignIntegral, getFrontUserInfo, getUserInfo } = await import('@/api/user.js');
const { getUserPoints } = await import('@/api/tool.js');
// 子问题 A不得在 API 返回成功前修改 currentPoints避免打卡前积分提前跳变
// 子问题 B-1打卡接口GET /api/front/user/sign/integralsetSignIntegral与 /api/front/user/checkin 同属签到类接口
// 打卡接口GET /api/front/user/sign/integralsetSignIntegral等同于 checkin 签到
await setSignIntegral();
this.todaySigned = true;
// 子问题 B-2/B-3仅用服务端返回值更新积分禁止前端本地 +30。调用 GET /api/front/usergetUserInfo刷新用户信息将返回的 integral 赋给 currentPoints
const userRes = await getUserInfo();
// 子问题 B仅在打卡成功后用服务端数据更新积分。先 GET /api/front/user/info 刷新用户积分,禁止硬编码 +30
let userRes = null;
try {
userRes = await getFrontUserInfo(); // GET /api/front/user/info
} catch (_) {
userRes = await getUserInfo().catch(() => null);
}
if (userRes && userRes.data && (userRes.data.integral != null || userRes.data.points != null)) {
this.currentPoints = userRes.data.integral ?? userRes.data.points ?? 0;
} else {
@@ -261,6 +264,9 @@ export default {
this.currentPoints = serverPoints;
}
}
// 积分已从服务端更新后再更新打卡状态并跳转,避免“已打卡”与积分不同步
this.todaySigned = true;
} catch (e) {
const msg = (typeof e === 'string' ? e : (e && (e.message || e.msg))) || '打卡失败';
if (msg.includes('今日已签到') || msg.includes('不可重复')) {