Initial commit
This commit is contained in:
150
docs/api/admin.md
Normal file
150
docs/api/admin.md
Normal file
@@ -0,0 +1,150 @@
|
||||
# 管理员 API
|
||||
|
||||
所有管理员 API 都需要在请求头中携带 Bearer Token:
|
||||
|
||||
```http
|
||||
Authorization: Bearer <token>
|
||||
```
|
||||
|
||||
## 管理员登录
|
||||
|
||||
获取管理员 Token。
|
||||
|
||||
### 请求
|
||||
|
||||
```http
|
||||
POST /admin/login
|
||||
Content-Type: application/json
|
||||
```
|
||||
|
||||
### 请求体
|
||||
|
||||
```json
|
||||
{
|
||||
"username": "admin",
|
||||
"password": "your_password"
|
||||
}
|
||||
```
|
||||
|
||||
### 响应示例
|
||||
|
||||
```json
|
||||
{
|
||||
"success": true,
|
||||
"data": {
|
||||
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
|
||||
"expiresIn": 604800
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## 获取评论管理列表
|
||||
|
||||
获取所有评论列表(包括待审核的评论)。
|
||||
|
||||
### 请求
|
||||
|
||||
```http
|
||||
GET /admin/comments/list?page={page}&pageSize={pageSize}&status={status}
|
||||
Authorization: Bearer <token>
|
||||
```
|
||||
|
||||
### 参数
|
||||
|
||||
| 参数 | 类型 | 必填 | 说明 |
|
||||
| -------- | ------ | ---- | ----------------------------------- |
|
||||
| page | number | 否 | 页码,默认 1 |
|
||||
| pageSize | number | 否 | 每页数量,默认 20 |
|
||||
| status | string | 否 | 状态筛选:pending/approved/rejected |
|
||||
|
||||
### 响应示例
|
||||
|
||||
```json
|
||||
{
|
||||
"success": true,
|
||||
"data": {
|
||||
"comments": [
|
||||
{
|
||||
"id": 1,
|
||||
"path": "/blog/hello-world",
|
||||
"author": "张三",
|
||||
"email": "zhangsan@example.com",
|
||||
"content": "很棒的文章!",
|
||||
"parent_id": null,
|
||||
"status": "pending",
|
||||
"created_at": "2026-01-13T10:00:00Z"
|
||||
}
|
||||
],
|
||||
"total": 1,
|
||||
"page": 1,
|
||||
"pageSize": 20
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## 更新评论状态
|
||||
|
||||
审核评论,更新评论状态。
|
||||
|
||||
### 请求
|
||||
|
||||
```http
|
||||
PUT /admin/comments/status
|
||||
Authorization: Bearer <token>
|
||||
Content-Type: application/json
|
||||
```
|
||||
|
||||
### 请求体
|
||||
|
||||
```json
|
||||
{
|
||||
"id": 1,
|
||||
"status": "approved"
|
||||
}
|
||||
```
|
||||
|
||||
### 参数说明
|
||||
|
||||
| 参数 | 类型 | 必填 | 说明 |
|
||||
| ------ | ------ | ---- | ---------------------------------------- |
|
||||
| id | number | 是 | 评论 ID |
|
||||
| status | string | 是 | 状态:approved(通过)/ rejected(拒绝) |
|
||||
|
||||
### 响应示例
|
||||
|
||||
```json
|
||||
{
|
||||
"success": true,
|
||||
"data": {
|
||||
"message": "评论状态已更新"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## 删除评论
|
||||
|
||||
删除指定评论。
|
||||
|
||||
### 请求
|
||||
|
||||
```http
|
||||
DELETE /admin/comments/delete?id={id}
|
||||
Authorization: Bearer <token>
|
||||
```
|
||||
|
||||
### 参数
|
||||
|
||||
| 参数 | 类型 | 必填 | 说明 |
|
||||
|------|------|------|------|
|
||||
| id | number | 是 | 评论 ID |
|
||||
|
||||
### 响应示例
|
||||
|
||||
```json
|
||||
{
|
||||
"success": true,
|
||||
"data": {
|
||||
"message": "评论已删除"
|
||||
}
|
||||
}
|
||||
```
|
||||
48
docs/api/overview.md
Normal file
48
docs/api/overview.md
Normal file
@@ -0,0 +1,48 @@
|
||||
# API 概览
|
||||
|
||||
## 基础信息
|
||||
|
||||
- **Base URL**: `https://your-worker.workers.dev`
|
||||
- **数据格式**: JSON
|
||||
- **字符编码**: UTF-8
|
||||
|
||||
## 认证方式
|
||||
|
||||
管理员 API 需要使用 Bearer Token 认证:
|
||||
|
||||
```http
|
||||
Authorization: Bearer <token>
|
||||
```
|
||||
|
||||
Token 通过登录接口获取,有效期为 24 小时。
|
||||
|
||||
## 响应格式
|
||||
|
||||
### 成功响应
|
||||
|
||||
```json
|
||||
{
|
||||
"success": true,
|
||||
"data": { ... }
|
||||
}
|
||||
```
|
||||
|
||||
### 错误响应
|
||||
|
||||
```json
|
||||
{
|
||||
"success": false,
|
||||
"error": "错误信息"
|
||||
}
|
||||
```
|
||||
|
||||
## HTTP 状态码
|
||||
|
||||
| 状态码 | 说明 |
|
||||
| ------ | ------------ |
|
||||
| 200 | 请求成功 |
|
||||
| 400 | 请求参数错误 |
|
||||
| 401 | 未授权 |
|
||||
| 403 | 禁止访问 |
|
||||
| 404 | 资源不存在 |
|
||||
| 500 | 服务器错误 |
|
||||
90
docs/api/public.md
Normal file
90
docs/api/public.md
Normal file
@@ -0,0 +1,90 @@
|
||||
# 公开 API
|
||||
|
||||
## 获取评论列表
|
||||
|
||||
获取指定页面的评论列表。
|
||||
|
||||
### 请求
|
||||
|
||||
```http
|
||||
GET /api/comments?path={path}&page={page}&pageSize={pageSize}
|
||||
```
|
||||
|
||||
### 参数
|
||||
|
||||
| 参数 | 类型 | 必填 | 说明 |
|
||||
| -------- | ------ | ---- | ----------------- |
|
||||
| path | string | 是 | 页面路径 |
|
||||
| page | number | 否 | 页码,默认 1 |
|
||||
| pageSize | number | 否 | 每页数量,默认 10 |
|
||||
|
||||
### 响应示例
|
||||
|
||||
```json
|
||||
{
|
||||
"success": true,
|
||||
"data": {
|
||||
"comments": [
|
||||
{
|
||||
"id": 1,
|
||||
"path": "/blog/hello-world",
|
||||
"author": "张三",
|
||||
"email": "zhangsan@example.com",
|
||||
"content": "很棒的文章!",
|
||||
"parent_id": null,
|
||||
"status": "approved",
|
||||
"created_at": "2026-01-13T10:00:00Z",
|
||||
"avatar": "https://gravatar.com/avatar/..."
|
||||
}
|
||||
],
|
||||
"total": 1,
|
||||
"page": 1,
|
||||
"pageSize": 10
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## 提交评论
|
||||
|
||||
提交新评论。
|
||||
|
||||
### 请求
|
||||
|
||||
```http
|
||||
POST /api/comments
|
||||
Content-Type: application/json
|
||||
```
|
||||
|
||||
### 请求体
|
||||
|
||||
```json
|
||||
{
|
||||
"path": "/blog/hello-world",
|
||||
"author": "张三",
|
||||
"email": "zhangsan@example.com",
|
||||
"content": "很棒的文章!",
|
||||
"parent_id": null
|
||||
}
|
||||
```
|
||||
|
||||
### 参数说明
|
||||
|
||||
| 参数 | 类型 | 必填 | 说明 |
|
||||
| --------- | ------ | ---- | ----------------------- |
|
||||
| path | string | 是 | 页面路径 |
|
||||
| author | string | 是 | 评论者昵称 |
|
||||
| email | string | 是 | 评论者邮箱 |
|
||||
| content | string | 是 | 评论内容 |
|
||||
| parent_id | number | 否 | 父评论 ID(回复时使用) |
|
||||
|
||||
### 响应示例
|
||||
|
||||
```json
|
||||
{
|
||||
"success": true,
|
||||
"data": {
|
||||
"id": 1,
|
||||
"message": "评论提交成功,等待审核"
|
||||
}
|
||||
}
|
||||
```
|
||||
Reference in New Issue
Block a user