重构板块资金流向:行业/概念改用独立 path,后端排序,前端不缓存直接请求

This commit is contained in:
Sakurasan
2026-07-13 23:22:09 +08:00
parent 94d84a368f
commit eea2ce86d0
3 changed files with 111 additions and 59 deletions
+12 -4
View File
@@ -460,15 +460,23 @@ export interface SectorResponse {
}
/**
* 获取东方财富板块列表(按主力净流入排序)
* 获取东方财富板块列表
* 行业/概念走不同 path(/industry、/concept),避免上游反代按 path 缓存忽略 query 导致数据串味
* @param type industry=行业板块, concept=概念板块
* @param sort mainNetInflow=资金流入, changePercent=涨幅%
* @param order asc=升序, desc=降序
*/
export async function fetchSectors(type: SectorType, signal?: AbortSignal): Promise<SectorItem[]> {
export async function fetchSectors(
type: SectorType,
opts?: { sort?: "mainNetInflow" | "changePercent"; order?: "asc" | "desc"; signal?: AbortSignal },
): Promise<SectorItem[]> {
const baseUrl = getApiBaseUrl();
const url = `${baseUrl}/api/sectors?type=${type}`;
const sort = opts?.sort ?? "mainNetInflow";
const order = opts?.order ?? "desc";
const url = `${baseUrl}/api/sectors/${type}?sort=${sort}&order=${order}`;
try {
const resp = await fetch(url, { method: "GET", signal, cache: "no-store" });
const resp = await fetch(url, { method: "GET", signal: opts?.signal, cache: "no-store" });
if (!resp.ok) return [];
const result: SectorResponse = await resp.json();
return result.data || [];