Files
Mdeical_Sur_Report/工程分析/需求分析-2026-04-19-03-19-57.md
admin 854a00c2fa fix(editor): Checkbox点击失效 + AI全局上下文注入
- 将'允许修改正文'复选框从id/htmlFor绑定改为label直接包裹input,增加e.stopPropagation防止事件冒泡被拦截
- handleAIGenerate中新增editorRef.current.innerText作为全局上下文注入prompt
- currentHtml增加过滤​零宽字符
- 优化systemPrompt,明确告知大模型全局参考内容+目标区域源码的双信息源结构
2026-04-19 03:35:52 +08:00

32 lines
1.4 KiB
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-19-03-19-57
## 1. 需求背景
AI 撰写功能仍存在两个体验与错误问题:
1. **AI 输入框内容丢失**:用户在 textarea 中输入了文字但未发送,切换页面再返回后,输入框内容清空
2. **API 400 Bad Request**不带图片发送消息时Kimi API 返回 400。因为当前代码始终将 `content` 包装为数组Vision 格式),而纯文本模型要求 `content` 为字符串
## 2. 需求拆解
- [ ] **Task 1chatInput 持久化**
- `stateRef` 增加 `chatInput`
- `saveDraftToStorage` 保存 `chatInput`
- 草稿恢复时恢复 `chatInput`
- `useEffect` 监听 `chatInput` 同步到 `stateRef`
- [ ] **Task 2API content 格式自适应**
- 无图片时:`content` 为纯字符串(兼容 Kimi / DeepSeek
- 有图片时:`content` 为 OpenAI Vision 数组格式(兼容 GPT-4o / Qwen-VL
## 3. 影响范围
| 文件 | 修改类型 | 风险等级 |
|------|----------|----------|
| `src/pages/ReportEditor.tsx` | 修改(持久化 + API 请求体) | 中 |
## 4. 优先级
- P0API 400 修复(功能完全不可用)
- P1chatInput 持久化(体验优化)
## 5. 验收标准
- [ ] 不带图片发送消息时Kimi API 返回 200 而非 400
- [ ] 带图片发送消息时,仍使用 Vision 数组格式
- [ ] 在 AI 输入框输入文字后切换页面再返回,文字保留
- [ ] `npm run lint` 无类型错误