根因:切换账号时 saveCurrentAccountData() 耗时 ~7 秒,期间定时器仍在发 API 请求, clear 阶段 token 被删除后 in-flight 请求收到 401 → 触发 tokenExpired → logoutCurrentAccount() 把刚恢复的新账号数据全部擦除。 修复(两层防护): 1. 全局锁 isSwitchingAccount:MultiAccountService 在 switchToAccount 整个过程中 设为 true,app.dart _handleTokenExpired 检测到该标志直接 return,不执行 logout 2. 定时器提前停止:将定时器停止从 onBeforeRestore(save 之后)移到 switchToAccount 调用之前,确保 save 期间无新 API 请求 3. try/finally 保证标志位必定清除,异常情况不会锁死后续 tokenExpired 事件 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> |
||
|---|---|---|
| .. | ||
| core | ||
| features | ||
| routes | ||
| app.dart | ||
| bootstrap.dart | ||
| main.dart | ||