2.0 KiB
2.0 KiB
API 接口文档
我是卡若。
这是前后端对接的“合同”。所有字段必须严格对齐。
1. 全局配置
- Base URL:
/api
2. 内容模块
2.1 获取目录树
- URL:
/content/tree - Method:
GET - 描述: 获取整本书的章节结构。
- Response:
{ "code": 0, "data": [ { "id": "part-1", "title": "第一篇:真实的人", "type": "part", "children": [ { "id": "chapter-1", "title": "第1章:底层逻辑", "type": "chapter", "children": [ { "id": "1.1", "title": "1.1 自行车荷总", "path": "book/第一篇/第1章/1.1.md", "type": "article" } ] } ] } ] }
2.2 获取文章详情
- URL:
/content/article - Method:
GET - Query:
path(文件路径) - Response:
{ "code": 0, "data": { "title": "1.1 自行车荷总", "content": "# Markdown内容...", "prev": { "title": "序言", "path": "..." }, "next": { "title": "1.2 老墨", "path": "..." } } }
3. 业务模块
3.1 获取全局配置
- URL:
/config - Method:
GET - Response:
{ "code": 0, "data": { "wechat_id": "28533368", "qrcode_url": "/images/qrcode.jpg", "price": 29.9 } }
3.2 埋点上报
- URL:
/track - Method:
POST - Body:
{ "event": "click_wechat", "page": "1.1.md", "timestamp": 1712345678 } - Response:
{ "code": 0 }
4. 管理模块 (需鉴权)
4.1 生成文档
- URL:
/admin/generate-doc - Method:
POST - Headers:
Authorization: Bearer <token> - Body:
{ "format": "docx" } - Response: Binary Stream (文件下载)
卡若说: 接口越少越好,参数越简单越好。