From 7b8e0e7e32f1d74050e44199200820ad1d184e59 Mon Sep 17 00:00:00 2001 From: xianyi Date: Tue, 13 Jan 2026 17:15:59 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=8D=B3=E5=B0=86=E5=88=B0?= =?UTF-8?q?=E6=9D=A5=E6=AF=94=E8=B5=9B=E5=88=97=E8=A1=A8=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- constants/api.ts | 1 + lib/api.ts | 30 ++++++++++++++++++++++++++++++ types/api.ts | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 77 insertions(+) diff --git a/constants/api.ts b/constants/api.ts index 6509dd5..3cfef29 100644 --- a/constants/api.ts +++ b/constants/api.ts @@ -8,5 +8,6 @@ export const API_ENDPOINTS = { COUNTRIES: "/v1/api/countries", LEAGUES: "/v1/api/leagues", MATCHES_TODAY: "/v1/api/matches/today", + UPCOMING_MATCHES: "/v1/api/matches/upcoming", MATCH_DETAIL: (id: string) => `/v1/api/matches/${id}`, }; diff --git a/lib/api.ts b/lib/api.ts index 2f0d7c7..13ad268 100644 --- a/lib/api.ts +++ b/lib/api.ts @@ -7,6 +7,7 @@ import { Match, MatchDetailData, Sport, + UpcomingMatch, } from "@/types/api"; import axios from "axios"; @@ -108,3 +109,32 @@ export const fetchMatchDetail = async ( throw error; } }; + +export const fetchUpcomingMatches = async ( + sportId: number, + leagueKey: string, + limit: number = 50 +): Promise => { + try { + const response = + await apiClient.get>>( + 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; + } +}; diff --git a/types/api.ts b/types/api.ts index 29007b9..2097573 100644 --- a/types/api.ts +++ b/types/api.ts @@ -99,6 +99,52 @@ export interface Player { 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 { events: any[]; match: {