超腾开源平台仪表盘模块
本文档介绍了仪表盘模块的API,该模块用于查询和展示平台各项关键指标的统计概览。核心内容包括两个主要接口:一是通过GET请求获取缓存的系统统计数据,涵盖用户、博客、订单、访问量等数十项指标;二是通过POST请求强制刷新数据以获取最新统计。文档提供了详细的接口地址、认证要求、响应示例及字段说明,并附有Python、JavaScript和cURL的使用示例。注意事项指出数据默认有缓存,刷新接口会消耗较多资源,且所有访问均需认证。
仪表盘模块提供系统统计数据的查询功能,用于展示平台各项指标的统计概览。
API 接口
获取仪表盘统计数据
获取系统的各项统计数据,包括用户、博客、订单等关键指标。
接口地址: GET /api/dashboard/stats
请求参数: 无
需要认证: 是
响应示例:
{
"success": true,
"code": 200,
"msg": "操作成功",
"data": {
"apps": 5,
"users": 120,
"blogs": 350,
"blogs_draft": 25,
"blog_comments": 1200,
"blog_comments_draft": 35,
"feedbacks": 85,
"feedbacks_pending": 12,
"feedbacks_processing": 50,
"wikis": 200,
"wiki_comments": 500,
"wiki_comments_pending": 15,
"email_subscriptions": 300,
"email_subscriptions_verified": 250,
"links": 45,
"links_pending": 8,
"orders": 800,
"orders_paid": 650,
"items": 150,
"items_out_of_stock": 10,
"item_reviews": 1200,
"item_reviews_pending": 25,
"softwares": 30,
"software_draft": 5,
"agents": 20,
"llm_models": 15,
"llm_providers": 8,
"llm_prompts": 100,
"remote_hosts": 5,
"remote_hosts_online": 4,
"spider_logs": 5000,
"spider_logs_today": 200,
"notifications": 500,
"notifications_unread": 15,
"today_pv": 2500,
"today_uv": 800,
"today_ip": 750,
"today_direct_visits": 500,
"today_referral_visits": 300,
"today_search_visits": 1200,
"today_social_visits": 100,
"today_new_visitors": 200,
"today_returning_visitors": 600
}
}
响应字段说明:
| 字段 | 类型 | 说明 |
|---|---|---|
| apps | int | 应用数量 |
| users | int | 用户数量 |
| blogs | int | 博客数量 |
| blogs_draft | int | 草稿博客数量 |
| blog_comments | int | 博客评论数量 |
| blog_comments_draft | int | 待审核的博客评论数 |
| feedbacks | int | 反馈数量 |
| feedbacks_pending | int | 待处理的反馈数 |
| feedbacks_processing | int | 已处理的反馈数 |
| wikis | int | Wiki 数量 |
| wiki_comments | int | Wiki 评论数量 |
| wiki_comments_pending | int | 待审核的 Wiki 评论数 |
| email_subscriptions | int | 邮件订阅数量 |
| email_subscriptions_verified | int | 已验证的邮件订阅数 |
| links | int | 友情链接数量 |
| links_pending | int | 待审核的友情链接数 |
| orders | int | 订单数量 |
| orders_paid | int | 已付款的订单数 |
| items | int | 商品数量 |
| items_out_of_stock | int | 库存不足的商品数 |
| item_reviews | int | 商品评价数量 |
| item_reviews_pending | int | 待审核的商品评价数 |
| softwares | int | 软件数量 |
| software_draft | int | 草稿软件数 |
| agents | int | 智能体数量 |
| llm_models | int | 大模型数量 |
| llm_providers | int | 大模型提供商数量 |
| llm_prompts | int | 提示词数量 |
| remote_hosts | int | 远程主机数量 |
| remote_hosts_online | int | 在线的远程主机数 |
| spider_logs | int | 搜索引擎爬虫访问日志数量 |
| spider_logs_today | int | 今天的搜索引擎爬虫访问日志数量 |
| notifications | int | 消息通知数量 |
| notifications_unread | int | 未读的消息通知数 |
| today_pv | int | 今日页面浏览量(PV) |
| today_uv | int | 今日独立访客数(UV) |
| today_ip | int | 今日独立 IP 数 |
| today_direct_visits | int | 今日直接访问数 |
| today_referral_visits | int | 今日外部链接访问数 |
| today_search_visits | int | 今日搜索引擎访问数 |
| today_social_visits | int | 今日社交媒体访问数 |
| today_new_visitors | int | 今日新访客数 |
| today_returning_visitors | int | 今日回访访客数 |
强制刷新仪表盘统计数据
强制刷新仪表盘统计数据,清除缓存后重新获取最新的统计信息。
接口地址: POST /api/dashboard/stats/refresh
请求参数: 无
需要认证: 是
响应示例:
{
"success": true,
"code": 200,
"msg": "统计数据已刷新",
"data": {
"apps": 5,
"users": 121,
"blogs": 351,
...
}
}
使用示例
Python 示例
import requests
# 获取仪表盘统计数据
response = requests.get(
'http://localhost:8000/api/dashboard/stats',
headers={'Authorization': 'Bearer YOUR_ACCESS_TOKEN'}
)
if response.status_code == 200:
data = response.json()
if data['success']:
stats = data['data']
print(f"用户数量: {stats['users']}")
print(f"博客数量: {stats['blogs']}")
print(f"今日访问量: {stats['today_pv']}")
JavaScript 示例
// 获取仪表盘统计数据
async function getDashboardStats() {
const response = await fetch("http://localhost:8000/api/dashboard/stats", {
headers: {
Authorization: "Bearer YOUR_ACCESS_TOKEN",
},
});
const data = await response.json();
if (data.success) {
const stats = data.data;
console.log("用户数量:", stats.users);
console.log("博客数量:", stats.blogs);
console.log("今日访问量:", stats.today_pv);
}
}
cURL 示例
# 获取仪表盘统计数据
curl -X GET "http://localhost:8000/api/dashboard/stats" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN"
# 强制刷新仪表盘统计数据
curl -X POST "http://localhost:8000/api/dashboard/stats/refresh" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN"
注意事项
- 缓存机制: 仪表盘统计数据默认会缓存,以提高性能。如需获取最新数据,请调用强制刷新接口。
- 性能考虑: 强制刷新接口会清除缓存并重新计算所有统计数据,可能会消耗较多服务器资源,建议不要频繁调用。
- 数据更新频率: 仪表盘统计数据通常定时更新,具体频率取决于系统配置。
- 权限要求: 访问仪表盘数据需要登录认证,普通用户和管理员都可以访问。
相关文档
本文由人工编写,AI优化,转载请注明原文地址: 超腾开源平台仪表盘模块
推荐阅读
评论 (0)
发表评论
昵称:加载中...
暂无评论,快来发表第一条评论吧!