diff --git a/AGENTS.md b/AGENTS.md index 160eb3c..095a96c 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -61,6 +61,10 @@ nginx:`root /opt/app` + `Cache-Control: no-cache` + `etag on` —— 缓存靠 ⚠️ **只认「返回回到本页」三种情形**(bfcache 的 `pageshow.persisted`、后退重载的 `navigation.type === 'back_forward'`、从应用页 `location.href` 回来的 `document.referrer`); **绝不能改成「每次加载都清」** —— 宿主恢复会把本页当返回落点加载,误清会毁掉刚用上的记录。 +9. **保存资料失败必须提示,不能静默**(2026-09-22「档案以上游为准」): + `PUT /profile` 改**预产期/昵称**时,后端会**先推上游用户中心、成功才落库**,推失败返回 `code=400` 且 + **不落库**。H5 必须弹提示(`_putProfile` 已按此判断 `res.code`)——静默的话下次加载会被上游值覆盖回去, + 用户以为"改了没生效"。改这个接口的调用方时别再把失败吞掉。 ## 5. 踩坑 diff --git a/index.html b/index.html index 9934141..85fa0df 100644 --- a/index.html +++ b/index.html @@ -7,7 +7,7 @@ 兜爸心选 · 孕育陪伴 - + diff --git a/js/app.js b/js/app.js index 02f26f4..8db916f 100644 --- a/js/app.js +++ b/js/app.js @@ -3,7 +3,7 @@ (function () { 'use strict'; /* 页面版本号(YYMMDD+序号):显示在「关于兜爸心选」页底部;bump 时同步 head 注释与 ?v= */ - var VER = '26092203'; + var VER = '26092204'; const $ = (s, c) => (c || document).querySelector(s); const $$ = (s, c) => Array.from((c || document).querySelectorAll(s)); @@ -1245,10 +1245,20 @@ method: 'PUT', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(body) - }).then(function () { + }).then(function (r) { + return r.json().catch(function () { return null; }); + }).then(function (res) { + /* ⚠️ 2026-09-22(档案以上游为准):预产期/昵称会**先推上游、推失败后端返回 400 且不落库**。 + 这里必须让用户看见失败 —— 静默的话下次加载会被上游值覆盖回去,用户以为"改了没生效"。 */ + if (!res || res.code !== 200) { + toast((res && res.message) || '保存失败,请检查网络后重试'); + return; + } /* 新用户首次完善资料:重载页面 → pregnancy 出真实孕周 */ if (_wasEmpty) setTimeout(bustReload, 700); - }).catch(function () { /* 保持本地值 */ }); + }).catch(function () { + toast('保存失败,请检查网络后重试'); + }); } var newAvatarFile = (avFile.files && avFile.files[0]) || null; if (newAvatarFile && avBig.classList.contains('has-img')) {