添加即将到来比赛列表接口
This commit is contained in:
@@ -8,5 +8,6 @@ export const API_ENDPOINTS = {
|
|||||||
COUNTRIES: "/v1/api/countries",
|
COUNTRIES: "/v1/api/countries",
|
||||||
LEAGUES: "/v1/api/leagues",
|
LEAGUES: "/v1/api/leagues",
|
||||||
MATCHES_TODAY: "/v1/api/matches/today",
|
MATCHES_TODAY: "/v1/api/matches/today",
|
||||||
|
UPCOMING_MATCHES: "/v1/api/matches/upcoming",
|
||||||
MATCH_DETAIL: (id: string) => `/v1/api/matches/${id}`,
|
MATCH_DETAIL: (id: string) => `/v1/api/matches/${id}`,
|
||||||
};
|
};
|
||||||
|
|||||||
30
lib/api.ts
30
lib/api.ts
@@ -7,6 +7,7 @@ import {
|
|||||||
Match,
|
Match,
|
||||||
MatchDetailData,
|
MatchDetailData,
|
||||||
Sport,
|
Sport,
|
||||||
|
UpcomingMatch,
|
||||||
} from "@/types/api";
|
} from "@/types/api";
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
|
|
||||||
@@ -108,3 +109,32 @@ export const fetchMatchDetail = async (
|
|||||||
throw 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,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
if (response.data.code === 0) {
|
||||||
|
return response.data.data.list;
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new Error(response.data.message);
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Fetch upcoming matches error:", error);
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|||||||
46
types/api.ts
46
types/api.ts
@@ -99,6 +99,52 @@ export interface Player {
|
|||||||
position?: string; // 兜底位置字段
|
position?: string; // 兜底位置字段
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface UpcomingMatch {
|
||||||
|
id: number;
|
||||||
|
eventKey: string;
|
||||||
|
sportId: number;
|
||||||
|
leagueKey: string;
|
||||||
|
leagueName: string;
|
||||||
|
leagueLogo: string;
|
||||||
|
leagueGroup: string;
|
||||||
|
countryKey: string;
|
||||||
|
countryName: string;
|
||||||
|
countryLogo: string;
|
||||||
|
season: string;
|
||||||
|
round: string;
|
||||||
|
stageName: string;
|
||||||
|
eventDate: string;
|
||||||
|
eventTime: string;
|
||||||
|
status: string; // scheduled
|
||||||
|
venue: string;
|
||||||
|
referee: string;
|
||||||
|
homeTeamKey: string;
|
||||||
|
homeTeamName: string;
|
||||||
|
homeTeamLogo: string;
|
||||||
|
homeFormation: string;
|
||||||
|
homeScore: number;
|
||||||
|
homeHalfScore: number;
|
||||||
|
homeShots: number;
|
||||||
|
homeShotsOnTarget: number;
|
||||||
|
homePossession: number;
|
||||||
|
homeYellowCards: number;
|
||||||
|
homeRedCards: number;
|
||||||
|
awayTeamKey: string;
|
||||||
|
awayTeamName: string;
|
||||||
|
awayTeamLogo: string;
|
||||||
|
awayFormation: string;
|
||||||
|
awayScore: number;
|
||||||
|
awayHalfScore: number;
|
||||||
|
awayShots: number;
|
||||||
|
awayShotsOnTarget: number;
|
||||||
|
awayPossession: number;
|
||||||
|
awayYellowCards: number;
|
||||||
|
awayRedCards: number;
|
||||||
|
eventLive: boolean;
|
||||||
|
createdAt: string;
|
||||||
|
updatedAt: string;
|
||||||
|
}
|
||||||
|
|
||||||
export interface MatchDetailData {
|
export interface MatchDetailData {
|
||||||
events: any[];
|
events: any[];
|
||||||
match: {
|
match: {
|
||||||
|
|||||||
Reference in New Issue
Block a user