feat: 题材热点历史页展示最近10个交易日题材涨幅矩阵

This commit is contained in:
Sakurasan
2026-08-27 20:18:51 +08:00
parent 57548c791d
commit 86d0dded3a
5 changed files with 218 additions and 1 deletions
+29
View File
@@ -3,6 +3,35 @@ import { getApiBaseUrl } from "@/lib/api-client";
/* ── 题材列表 ── */
export interface ActiveTheme {
themeCode: string;
themeName: string;
dailyGains: Record<string, number | null>; // trade_date -> 当日题材涨幅 bf3(可空)
appearCount: number; // 窗口内上榜次数
lastAppear: string | null; // 最近上榜交易日
bestRank: number | null; // 窗口内最佳排名(rank 最小值)
}
export interface ActiveThemesResponse {
dates: string[];
themes: ActiveTheme[];
}
/**
* 获取最近 10 个交易日的活跃题材涨幅矩阵
*/
export async function fetchActiveThemes(): Promise<ActiveThemesResponse> {
const baseUrl = getApiBaseUrl();
try {
const resp = await fetch(`${baseUrl}/api/themes/active`, { method: "GET", cache: "no-store" });
if (!resp.ok) return { dates: [], themes: [] };
return resp.json();
} catch (err) {
console.error("[theme-api] 获取活跃题材历史失败:", err);
return { dates: [], themes: [] };
}
}
export interface ThemeItem {
themeCode: string;
themeName: string;