Files
wecom-ai-assistant/docs/phase3.md
2026-02-05 16:36:32 +08:00

36 lines
1.8 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.
# Phase 3管理后台基础页面 + API 联通
## 新增内容
- **前端**Next.js App Router路由组 `(main)` 下会话/知识库/设置共用布局
- **登录**`/login` → 存 token 到 localStorage → 跳转 `/sessions`
- **会话列表**`/sessions`,调用 `GET /api/sessions`,表格 + 查看消息链接
- **会话详情**`/sessions/[id]`,消息列表 + 手动回复输入 + 「转人工/创建工单」按钮
- **知识库**`/knowledge`,拖拽上传,调用 `POST /api/knowledge/upload`(占位)
- **设置**`/settings`,调用 `GET /api/settings`(占位)
- **API 封装**`lib/api.ts`,统一带 `Authorization: Bearer <token>`
## 本地启动
1. 后端与 DB 已起Phase 2`docker-compose up -d db backend` 或全栈 `docker-compose up -d`
2. 前端(从项目根):
- **Bash:** `cd admin``npm install``npm run dev`
- **PowerShell:** `cd admin``npm install` → 设置 API 再启动:
```powershell
$env:NEXT_PUBLIC_API_BASE="http://localhost:8000"; npm run dev
```
或新建 `admin/.env.local` 内容 `NEXT_PUBLIC_API_BASE=http://localhost:8000`,然后 `npm run dev`
3. 浏览器打开 `http://localhost:3000`,根路径会重定向到 `/login` 或 `/sessions`
## 验证
- 使用 `admin` / `admin` 登录(需已执行迁移并 seed
- 会话列表可为空Phase 5 入库后会有数据)
- 会话详情页可点「转人工/创建工单」、输入内容点「发送」(后端占位返回成功)
- 知识库页拖拽上传任意文件,应提示上传成功(占位)
- 设置页展示空对象 `{}`
## 关键配置
- `NEXT_PUBLIC_API_BASE`:前端请求的后端地址。本地直连填 `http://localhost:8000`;经 nginx 填 `http://localhost` 或留空(同域)