Initial upload for secondary development

This commit is contained in:
2026-06-08 19:00:03 +08:00
commit b913b8c78c
81 changed files with 27139 additions and 0 deletions

87
chatlab-web/README.md Normal file
View File

@@ -0,0 +1,87 @@
# ChatLab Web MVP
> 设备售后微信知识库 — Web 端 MVP
## 目录结构
```
chatlab-web/
├── frontend/ # React (Vite) 前端
└── backend/ # Python FastAPI 后端
```
> ⚠️ 此目录与 get_wechat 主项目完全独立,不修改任何现有文件
---
## 快速启动
### 1. 启动前端(含 Mock 数据,无需后端)
```bash
cd chatlab-web/frontend
npm run dev
# 浏览器访问 http://localhost:5173
```
### 2. 启动后端(接入 chatlog API
```bash
cd chatlab-web/backend
pip install -r requirements.txt
cp .env .env.local # 按需修改 CHATLOG_API 地址
python main.py
# 后端运行在 http://localhost:8000
```
### 3. 前端切换到真实后端
编辑 `frontend/src/api/index.js`,将 `USE_MOCK = true` 改为 `false`
---
## 接口说明
### 存量查询(前端主动拉取)
| 接口 | 方法 | 说明 |
|------|------|------|
| `/api/chatroom` | GET | 获取群聊列表 |
| `/api/v1/chatlog` | GET | 拉取存量聊天记录(分页) |
| `/api/session` | GET | 最近会话列表 |
| `/api/contact` | GET | 联系人搜索 |
### 增量推送Webhook → SSE
| 接口 | 方法 | 说明 |
|------|------|------|
| `/api/webhook` | POST | chatlog 推送新消息(配置到 chatlog |
| `/api/sse/chatlog?talker=群ID` | GET (SSE) | 前端订阅实时推送 |
| `/api/health` | GET | 健康检查 |
---
## chatlog API 对接
后端代理到 `http://127.0.0.1:5030`,参考接口:
```
GET /api/v1/chatlog?talker={群ID}&time={start,end}&limit={n}&offset={n}&format=json
POST {本后端 webhook URL} ← chatlog 配置 Webhook 推送地址
```
具体入参出参待确认后更新 `backend/main.py` 中的代理逻辑。
---
## MVP 功能范围
- [x] 深色主题 UI + 完整设计系统
- [x] 群聊列表 Sidebar
- [x] 聊天记录检索(时间范围 / 发送人多选 / 关键词)
- [x] 消息气泡展示(按天分组)
- [x] 关键词高亮
- [x] Webhook 增量接收 + SSE 实时推送
- [x] Mock 数据层(可一键切换真实 API
- [ ] AI 话题分类P0待接入
- [ ] 知识库P0待接入