feat(frontend-v2): #986 Token 驾驶舱真实数据页 (token/overview|rankings|logs|balance)
This commit is contained in:
1 parent
4a2920e637
commit
910394423d
4 files changed
+501
-35
No files matched your search
@@ -6,7 +6,8 @@ import {
|
||||
marketApi,
|
||||
imBotApi,
|
||||
profileApi,
|
||||
dashboardApi,
|
||||
tokenApi,
|
||||
type TokenOverview,
|
||||
} from '@/api/client';
|
||||
|
||||
// ─── Auth ───────────────────────────────────────────────────────────────────────
|
||||
@@ -127,7 +128,7 @@ export function useMarketApps() {
|
||||
return useQuery({
|
||||
queryKey: ['market', 'apps'],
|
||||
queryFn: marketApi.listApps,
|
||||
select: (d) => asArray(d),
|
||||
select: (d: unknown) => asArray(d),
|
||||
});
|
||||
}
|
||||
|
||||
@@ -135,7 +136,7 @@ export function useMyApps() {
|
||||
return useQuery({
|
||||
queryKey: ['market', 'my-apps'],
|
||||
queryFn: marketApi.getMyApps,
|
||||
select: (d) => asArray(d),
|
||||
select: (d: unknown) => asArray(d),
|
||||
});
|
||||
}
|
||||
|
||||
@@ -193,11 +194,58 @@ export function useUpdateProfile() {
|
||||
});
|
||||
}
|
||||
|
||||
// ─── Dashboard ───────────────────────────────────────────────────────────────────
|
||||
// ─── Token 驾驶舱 ─────────────────────────────────────────────────────────────────
|
||||
|
||||
// Landing hero still shows a few headline numbers; reuse the real token overview
|
||||
// so the homepage never ships fake/mock values.
|
||||
export function useDashboardStats() {
|
||||
return useQuery({
|
||||
queryKey: ['dashboard', 'stats'],
|
||||
queryFn: dashboardApi.getStats,
|
||||
queryKey: ['token', 'overview'],
|
||||
queryFn: tokenApi.getOverview,
|
||||
select: (d: TokenOverview) => ({
|
||||
active_users: d.today_apps,
|
||||
today_conversations: d.today_apps,
|
||||
skill_count: d.total_used,
|
||||
revenue: d.balance,
|
||||
user_change: '',
|
||||
conv_change: '',
|
||||
}),
|
||||
});
|
||||
}
|
||||
|
||||
export function useTokenOverview() {
|
||||
return useQuery({
|
||||
queryKey: ['token', 'overview'],
|
||||
queryFn: tokenApi.getOverview,
|
||||
refetchInterval: 60000, // 每分钟刷新一次概览
|
||||
});
|
||||
}
|
||||
|
||||
export function useTokenRankings() {
|
||||
return useQuery({
|
||||
queryKey: ['token', 'rankings'],
|
||||
queryFn: tokenApi.getRankings,
|
||||
});
|
||||
}
|
||||
|
||||
export function useTokenBalance() {
|
||||
return useQuery({
|
||||
queryKey: ['token', 'balance'],
|
||||
queryFn: tokenApi.getBalance,
|
||||
});
|
||||
}
|
||||
|
||||
export function useTokenLogs(params: {
|
||||
start_date?: string;
|
||||
end_date?: string;
|
||||
model_id?: string;
|
||||
app_type?: string;
|
||||
page?: number;
|
||||
page_size?: number;
|
||||
}) {
|
||||
return useQuery({
|
||||
queryKey: ['token', 'logs', params],
|
||||
queryFn: () => tokenApi.getLogs(params),
|
||||
placeholderData: (prev) => prev, // 翻页时保留旧数据,避免闪烁
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user