fix: 修复接口重复调用 — StrictMode 清理 + useModelList 去重

AppProvider useEffect 增加 aborted 标志,防止 React StrictMode
挂载→卸载→重新挂载时 refreshToken/getUserInfo 各调两次。

useModelList 提升到 LeftPanel 单例调用,通过 props 分发给
ModelSelector 和 TaskHistory,消除 /api/v1/models 重复请求。

DevTools 中显示「已停止」的请求即 StrictMode 第一轮挂载被丢弃的请求。

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-06-09 19:24:34 +08:00
parent d95d155ab5
commit 848fdeca3d
7 changed files with 58 additions and 11 deletions

View File

@@ -111,6 +111,10 @@ App 启动 → AppProvider useEffect
→ 否 → 跳过
```
> **StrictMode 清理**:该 useEffect 持有 `aborted` 标志cleanup 返回 `() => { aborted = true }`。
> 所有异步回调(`.then` / `.catch`)在操作 state 或发射事件前检查 `if (aborted) return`。
> 这防止 React StrictMode开发模式挂载→卸载→重新挂载时发起重复的 refreshToken / getUserInfo 请求。
### 3. 401 → 刷新 Token → 自动重试
```