Files
cwd/docs/api/public/analytics.md
anghunk 4a674ee17a docs: 重构API文档结构,合并子页面到主文档
将分散的API子页面内容合并到对应的主文档中,简化文档结构。具体合并内容包括:
- 将 verify-admin.md 内容合并到 auth.md
- 将 track-visit.md 内容合并到 analytics.md
- 将 get-config.md 内容合并到 config.md
- 将 get-comments.md、post-comment.md、like-comment.md 内容合并到 comments.md
- 将 get-like-status.md、post-like.md 内容合并到 like.md

删除原有的独立子页面文件,使API文档更加集中和易于维护。
2026-02-06 19:37:26 +08:00

72 lines
1.5 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.
# 访问统计
页面访问统计接口,用于记录和分析页面访问数据。
## 记录页面访问
```
POST /api/analytics/visit
```
前端组件在加载时调用此接口,记录页面访问数据,用于后台访问统计分析。
- 方法:`POST`
- 路径:`/api/analytics/visit`
- 鉴权:不需要
**请求头**
| 名称 | 必填 | 示例 |
| -------------- | ---- | ------------------ |
| `Content-Type` | 是 | `application/json` |
**请求体**
```json
{
"postSlug": "https://example.com/blog/hello-world",
"postTitle": "博客标题",
"postUrl": "https://example.com/blog/hello-world"
}
```
字段说明:
| 字段名 | 类型 | 必填 | 说明 |
| ----------- | ------ | ---- | -------------------------------------------------------------------- |
| `postSlug` | string | 是 | 文章唯一标识符,`window.location.origin + window.location.pathname` |
| `postTitle` | string | 否 | 文章标题,用于后台展示页面名称 |
| `postUrl` | string | 否 | 文章 URL用于后台展示页面链接和域名统计 |
**成功响应**
- 状态码:`200`
```json
{
"success": true
}
```
**错误响应**
- 缺少 `postSlug`
- 状态码:`400`
```json
{
"message": "postSlug is required"
}
```
- 服务器内部错误:
- 状态码:`500`
```json
{
"message": "记录访问数据失败"
! }
```