feat: 分离文章slug与URL字段并支持slug模式匹配查询

- 新增 `post_url` 字段存储文章完整URL,`post_slug` 仅存储标识符
- 更新管理后台评论列表、编辑、统计及域名获取接口以使用新字段
- 修改公共评论查询接口,支持slug精确匹配及带`?`、`#`参数的模糊匹配
- 更新前端管理界面,在评论编辑表单中增加"评论地址"(`postUrl`)字段
- 同步更新API文档,明确字段用途及查询参数说明
This commit is contained in:
anghunk
2026-02-09 13:36:25 +08:00
parent b2fd3e72e6
commit cf1e5b5c51
10 changed files with 135 additions and 51 deletions

View File

@@ -44,7 +44,8 @@ GET /admin/comments/list
"created": 1736762400000,
"name": "张三",
"email": "zhangsan@example.com",
"postSlug": "https://your-blog.example.com/blog/hello-world",
"postSlug": "hello-world",
"postUrl": "https://your-blog.example.com/blog/hello-world",
"url": "https://zhangsan.me",
"ipAddress": "127.0.0.1",
"contentText": "很棒的文章!",
@@ -63,6 +64,25 @@ GET /admin/comments/list
}
```
返回字段说明:
| 字段名 | 类型 | 说明 |
| ----------- | ------ | -------------------------- |
| `id` | number | 评论 ID |
| `created` | number | 创建时间戳 |
| `name` | string | 评论者昵称 |
| `email` | string | 评论者邮箱 |
| `postSlug` | string | 文章 slug |
| `postUrl` | string | null) | 文章完整 URL |
| `url` | string | null) | 评论者个人主页地址 |
| `ipAddress` | string | 评论者 IP 地址 |
| `contentText` | string | 评论内容(纯文本) |
| `contentHtml` | string | 评论内容(渲染后的 HTML |
| `status` | string | 评论状态 |
| `priority` | number | 置顶权重 |
| `ua` | string | 用户代理 |
| `avatar` | string | 头像 URLGravatar |
**鉴权错误**
- 未携带 Token 或 Token 失效:
@@ -156,7 +176,8 @@ PUT /admin/comments/update
"name": "张三",
"email": "zhangsan@example.com",
"url": "https://zhangsan.me",
"postSlug": "https://example.com/blog/hello-world",
"postSlug": "hello-world",
"postUrl": "https://example.com/blog/hello-world",
"contentText": "更新后的评论内容",
"status": "approved",
"priority": 2
@@ -171,10 +192,12 @@ PUT /admin/comments/update
| `name` | string | 是 | 评论者昵称 |
| `email` | string | 是 | 评论者邮箱 |
| `url` | string | 否 | 评论者个人主页或站点地址 |
| `postSlug` | string | 否 | 评论地址(文章 URL不传则保持原值 |
| `contentText` | string | | 评论内容(纯文本) |
`| `status` | string | | 评论状态,可选 `approved``pending``rejected` |
| `priority` | number | | 置顶权重,默认为 1数值越大越靠前 |
| `postSlug` | string | 否 | 文章 slug不传则保持原值支持 `postSlug` 或 `post_slug` |
| `postUrl` | string | | 文章完整 URL不传则保持原值支持 `postUrl` 或 `post_url` |
| `content` | string | 是* | 评论内容Markdown 或纯文本),与 `contentText` 二选一 |
| `contentText` | string | 是* | 评论内容(纯文本),与 `content` 二选一 |
| `status` | string | 否 | 评论状态,可选 `approved`、`pending`、`rejected` |
| `priority` | number | 否 | 置顶权重,默认为 1数值越大越靠前必须 >= 1 |
**置顶权重说明**