docs: 补充多站点数据隔离的配置和API文档

- 在站点隔离配置文档中详细说明 siteId 的使用方法和注意事项
- 为公开API接口添加 siteId 查询参数和请求头说明
- 更新前端配置文档,明确 siteId 为可选参数并说明默认值
- 修正常见问题中的表述和格式问题
This commit is contained in:
anghunk
2026-02-09 15:00:19 +08:00
parent 386bcfdeab
commit 3b429bf82c
6 changed files with 125 additions and 8 deletions

View File

@@ -30,6 +30,13 @@ POST /api/analytics/visit
}
```
**请求头**
| 名称 | 必填 | 示例 |
| -------------- | ---- | ---------------------------- |
| `Content-Type` | 是 | `application/json` |
| `X-Site-Id` | 否 | `blog` |
字段说明:
| 字段名 | 类型 | 必填 | 说明 |
@@ -38,6 +45,12 @@ POST /api/analytics/visit
| `postTitle` | string | 否 | 文章标题,用于后台展示页面名称 |
| `postUrl` | string | 否 | 文章 URL用于后台展示页面链接和域名统计 |
**请求头说明:**
| 名称 | 必填 | 说明 |
| ---------- | ---- | -------------------------- |
| `X-Site-Id` | 否 | 站点 ID用于多站点数据隔离默认 `default` |
**成功响应**
- 状态码:`200`

View File

@@ -19,6 +19,7 @@ GET /api/comments
| 名称 | 位置 | 类型 | 必填 | 说明 |
| ----------- | ----- | ------- | ---- | ------------------------------------------ |
| `post_slug` | query | string | 是 | 文章 slug与前端 `CWDComments``postSlug` 参数对应 |
| `siteId` | query | string | 否 | 站点 ID用于多站点数据隔离默认 `default` |
| `page` | query | integer | 否 | 页码,默认 `1` |
| `limit` | query | integer | 否 | 每页数量,默认 `20`,最大 `50` |
| `nested` | query | string | 否 | 是否返回嵌套结构,默认 `'true'` |
@@ -136,6 +137,13 @@ POST /api/comments
| -------------- | ---- | ---------------------------- |
| `Content-Type` | 是 | `application/json` |
**请求头**
| 名称 | 必填 | 示例 |
| -------------- | ---- | ---------------------------- |
| `Content-Type` | 是 | `application/json` |
| `X-Site-Id` | 否 | `blog` |
**请求体Request Body**
```json
@@ -160,12 +168,18 @@ POST /api/comments
| `post_title` | string | 否 | 文章标题,用于邮件通知内容 |
| `post_url` | string | 否 | 文章完整 URL用于邮件通知中的跳转链接 |
| `name` | string | 是 | 评论者昵称 |
| `email` | string | | 是 | 评论者邮箱,需为合法邮箱格式 |
| `email` | string | 是 | 评论者邮箱,需为合法邮箱格式 |
| `url` | string | 否 | 评论者个人主页或站点地址 |
| `content` | string | 是 | 评论内容,内部会过滤 `<script>...</script>` 片段 |
| `parent_id` | number | 否 | 父评论 ID用于回复功能缺省或 `null` 表示根评论 |
| `adminToken` | string | 否 | 管理员评论密钥,博主发布评论时需要先通过 `/api/verify-admin` 验证密钥后将密钥传入此字段,评论将直接通过且不受审核设置影响 |
**请求头说明:**
| 名称 | 必填 | 说明 |
| ---------- | ---- | -------------------------- |
| `X-Site-Id` | 否 | 站点 ID用于多站点数据隔离默认 `default` |
**成功响应**
- 状态码:`200`

View File

@@ -14,6 +14,12 @@ GET /api/config/comments
- 路径:`/api/config/comments`
- 鉴权:不需要
**查询参数**
| 名称 | 位置 | 类型 | 必填 | 说明 |
| -------- | ----- | ------ | ---- | -------------------------- |
| `siteId` | query | string | 否 | 站点 ID用于多站点数据隔离默认 `default` |
**成功响应**
- 状态码:`200`