Files
Pre_Seg_Server/工程分析/实现方案-20260429_231526.md

27 lines
1017 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 实现方案 — 2026-04-28
## R1/R2 — uploadMedia 字段修复
**文件**: `src/lib/api.ts`
**变更**:
- 解构 `response.data``file_url``object_name` 字段
- 返回 `{ url: file_url, id: object_name }` 以兼容前端既有接口
## R3 — 上传后刷新项目列表
**文件**: `src/components/ProjectLibrary.tsx`
**变更**:
- `uploadMedia()` resolve 后调用 `getProjects()``setProjects()` 写入 Zustand
- 失败时 alert 并打印错误
## R4 — WebSocket disconnect 崩溃修复
**文件**: `src/lib/websocket.ts`
**变更**:
- `disconnect()` 中仅当 `this.ws.readyState === WebSocket.OPEN` 时才调用 `.close()`
- 否则直接置空引用,避免对 CONNECTING 套接字调用 close
## R5 — StrictMode 竞态防护
**文件**: `src/components/Dashboard.tsx`
**变更**:
- 增加 `mounted` refcleanup 时置 `false`
- `onProgress` callback 与 `setInterval` callback 均检查 `mounted`
- 增加 500ms 延迟连接,避免 mount/unmount 过快时创建无意义连接