feat(web): 工作台页面改造 — 管理员/运营数据改用真实 API
- AdminDashboard 移除硬编码模块列表,改用 system-health/user-activity/modules API - OperatorWorkbench 移除硬编码积分动态和文章统计,改用 points-recent-activity/article-stats API - 新增 dashboard.ts API 客户端,AxiosResponse 解包到 data.data - Home.tsx 集成 4 个角色工作台组件路由 - useDashboardRole 支持 health_manager 角色
This commit is contained in:
69
apps/web/src/api/health/dashboard.ts
Normal file
69
apps/web/src/api/health/dashboard.ts
Normal file
@@ -0,0 +1,69 @@
|
||||
import client from '../client';
|
||||
|
||||
export interface ServiceHealthStatus {
|
||||
name: string;
|
||||
status: string;
|
||||
message: string;
|
||||
response_ms: number | null;
|
||||
}
|
||||
|
||||
export interface SystemHealthResp {
|
||||
services: ServiceHealthStatus[];
|
||||
checked_at: string;
|
||||
}
|
||||
|
||||
export interface RoleCount {
|
||||
role: string;
|
||||
count: number;
|
||||
}
|
||||
|
||||
export interface UserActivityResp {
|
||||
daily_active: number;
|
||||
weekly_active: number;
|
||||
monthly_active: number;
|
||||
total_registered: number;
|
||||
by_role: RoleCount[];
|
||||
}
|
||||
|
||||
export interface ModuleStatusResp {
|
||||
name: string;
|
||||
display_name: string;
|
||||
description: string;
|
||||
active: boolean;
|
||||
entity_count: number | null;
|
||||
route_count: number | null;
|
||||
}
|
||||
|
||||
export interface PointsActivityItem {
|
||||
id: string;
|
||||
user_name: string;
|
||||
detail: string;
|
||||
amount: string;
|
||||
type: string;
|
||||
created_at: string;
|
||||
}
|
||||
|
||||
export interface ArticleStatsResp {
|
||||
published: number;
|
||||
draft: number;
|
||||
pending_review: number;
|
||||
rejected: number;
|
||||
total_views: number;
|
||||
}
|
||||
|
||||
export const dashboardApi = {
|
||||
getSystemHealth: () =>
|
||||
client.get('/health/admin/system-health').then((r) => r.data.data as SystemHealthResp),
|
||||
|
||||
getUserActivity: () =>
|
||||
client.get('/health/admin/user-activity').then((r) => r.data.data as UserActivityResp),
|
||||
|
||||
getModuleStatus: () =>
|
||||
client.get('/health/admin/modules').then((r) => r.data.data as ModuleStatusResp[]),
|
||||
|
||||
getPointsRecentActivity: () =>
|
||||
client.get('/health/points/recent-activity').then((r) => r.data.data as PointsActivityItem[]),
|
||||
|
||||
getArticleStats: () =>
|
||||
client.get('/health/articles/stats').then((r) => r.data.data as ArticleStatsResp),
|
||||
};
|
||||
Reference in New Issue
Block a user