实现直播详情页

This commit is contained in:
yuchenglong
2026-01-14 18:15:13 +08:00
parent 8dc87c9b29
commit 025b483099
18 changed files with 2497 additions and 347 deletions

View File

@@ -4,6 +4,7 @@ import {
ApiResponse,
Country,
League,
LiveScoreMatch,
Match,
MatchDetailData,
OddsData,
@@ -138,23 +139,56 @@ export const fetchMatchDetail = async (
}
};
export const fetchLiveScore = async (
sportId: number,
leagueId?: number,
timezone?: string
): Promise<LiveScoreMatch[]> => {
try {
const params: { sport_id: number; league_id?: number; timezone?: string } =
{
sport_id: sportId,
};
if (leagueId) {
params.league_id = leagueId;
}
if (timezone) {
params.timezone = timezone;
}
const response = await apiClient.get<ApiResponse<LiveScoreMatch[]>>(
API_ENDPOINTS.LIVESCORE,
{ params }
);
if (response.data.code === 0) {
return response.data.data;
}
throw new Error(response.data.message);
} catch (error) {
console.error("Fetch livescore error:", error);
throw error;
}
};
export const fetchUpcomingMatches = async (
sportId: number,
leagueKey: string,
limit: number = 50
): Promise<UpcomingMatch[]> => {
try {
const response =
await apiClient.get<ApiResponse<ApiListResponse<UpcomingMatch>>>(
API_ENDPOINTS.UPCOMING_MATCHES,
{
params: {
sport_id: sportId,
leagueKey,
limit,
},
}
);
const response = await apiClient.get<
ApiResponse<ApiListResponse<UpcomingMatch>>
>(API_ENDPOINTS.UPCOMING_MATCHES, {
params: {
sport_id: sportId,
leagueKey,
limit,
},
});
if (response.data.code === 0) {
return response.data.data.list;