- 实现查询API (query.py): 支持star_id/unique_id/nickname三种查询方式 - 实现计算模块 (calculator.py): CPM/自然搜索UV/搜索成本计算 - 实现品牌API集成 (brand_api.py): 批量并发调用,10并发限制 - 实现导出服务 (export_service.py): Excel/CSV导出 - 前端组件: QueryForm/ResultTable/ExportButton - 主页面集成: 支持6种页面状态 - 测试: 44个测试全部通过,覆盖率88% Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
30 lines
795 B
TypeScript
30 lines
795 B
TypeScript
import { QueryRequest, QueryResponse } from '@/types';
|
|
|
|
const API_BASE_URL = process.env.NEXT_PUBLIC_API_URL || 'http://localhost:8000/api/v1';
|
|
|
|
export async function queryVideos(request: QueryRequest): Promise<QueryResponse> {
|
|
const response = await fetch(`${API_BASE_URL}/query`, {
|
|
method: 'POST',
|
|
headers: {
|
|
'Content-Type': 'application/json',
|
|
},
|
|
body: JSON.stringify(request),
|
|
});
|
|
|
|
if (!response.ok) {
|
|
throw new Error(`查询失败: ${response.statusText}`);
|
|
}
|
|
|
|
return response.json();
|
|
}
|
|
|
|
export async function exportData(format: 'xlsx' | 'csv'): Promise<Blob> {
|
|
const response = await fetch(`${API_BASE_URL}/export?format=${format}`);
|
|
|
|
if (!response.ok) {
|
|
throw new Error(`导出失败: ${response.statusText}`);
|
|
}
|
|
|
|
return response.blob();
|
|
}
|