Files
Pre_Seg_Server/工程分析/需求分析-2026-04-29-22-49-38.md

49 lines
2.0 KiB
Markdown
Raw Permalink 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-29-22-49-38
## 需求来源
- 提出时间: 2026-04-29-22-49-38
- 需求类型: 缺陷修复
## 原始需求描述
1. 项目库中视频显示"异常",且无法点击导入多媒体资源
2. 控制台 WebSocket 报错:
- `WebSocket connection to 'ws://localhost:8000/ws/progress' failed`
- `WebSocket is closed before the connection is established`
## 需求拆解
### 需求 1: 修复 WebSocket URLlocalhost → IP
- **详细描述**: `websocket.ts` 硬编码 `ws://localhost:8000/ws/progress`,浏览器解析为客户端本地地址导致连接失败
- **优先级**: P0-阻塞
- **影响范围**: `src/lib/websocket.ts`
- **验收标准**: WebSocket 连接到服务器实际 IP
### 需求 2: 后端添加 WebSocket 路由
- **详细描述**: FastAPI 后端未实现 `/ws/progress` WebSocket endpoint前端连接被拒绝
- **优先级**: P0-阻塞
- **影响范围**: `backend/main.py`
- **验收标准**: 后端接受 WebSocket 连接,可推送解析进度消息
### 需求 3: 修复"导入多媒体资源"按钮点击
- **详细描述**: `ProjectLibrary.tsx` 中按钮为纯静态 UI`onClick` 事件和文件输入框
- **优先级**: P0-阻塞
- **影响范围**: `src/components/ProjectLibrary.tsx`
- **验收标准**: 点击按钮弹出文件选择器,可选择视频/图片文件
### 需求 4: 修复项目状态显示"异常"
- **详细描述**: 后端数据库项目默认状态为 `'pending'`,前端只识别 `'Ready'``'Parsing'`,其他状态均显示"异常"
- **优先级**: P0-阻塞
- **影响范围**: `backend/models.py``src/components/ProjectLibrary.tsx`
- **验收标准**: 新建项目默认显示正确状态(非"异常"
## 约束条件
- 保持中文界面
- 最小修改原则
- 不破坏现有 API 契约
## 风险评估
| 风险点 | 影响 | 缓解措施 |
|--------|------|----------|
| WebSocket 实现复杂度高 | 中 | 先实现基础连接和心跳,进度推送后续完善 |
| 文件上传无后端对接 | 低 | 前端先实现文件选择器,调用已有 uploadMedia API |