feat(assets): add verified asset history trends and compact overview

This commit is contained in:
shishengliang
2026-10-24 13:16:48 +08:00
parent dbe0421bfe
commit 8afe13c9a3
36 changed files with 1716 additions and 9 deletions
+20
View File
@@ -0,0 +1,20 @@
import { fetchAuthenticated } from '../../../auth/api-client';
import type { HistoryMode, HistoryTrend, HistoryPoint, HistoryDetails, HistoryCategory } from '../../../shared/assets/history';
async function get<T>(path: string, params: Record<string, string | number | null | undefined>, signal: AbortSignal): Promise<T> {
const query = new URLSearchParams();
for (const [key, value] of Object.entries(params)) if (value != null && value !== '') query.set(key, String(value));
const response = await fetchAuthenticated(`/api/asset-history/${path}?${query}`, { signal });
const body = await response.json();
if (!response.ok) throw new Error(body.error || '历史趋势加载失败,请重试');
return body as T;
}
export function fetchHistoryTrend(mode: HistoryMode, year: number, subject: string | null, signal: AbortSignal) {
return get<HistoryTrend>('trend', { mode, year, subject }, signal);
}
export function fetchHistoryLive(mode: HistoryMode, subject: string | null, signal: AbortSignal) {
return get<HistoryPoint>('live', { mode, subject }, signal);
}
export function fetchHistoryDetails(month: string, batchId: string | null, subject: string | null, category: HistoryCategory, search: string, page: number, signal: AbortSignal) {
return get<HistoryDetails>('details', { month, batchId, subject, category, search, page, pageSize: 30 }, signal);
}