实现直播详情页赔率自动更新功能,优化赔率数据结构
This commit is contained in:
@@ -40,11 +40,26 @@ export default function LiveDetailScreen() {
|
||||
|
||||
useEffect(() => {
|
||||
loadLiveDetail();
|
||||
// 设置每 15 秒更新一次直播比分
|
||||
const timer = setInterval(() => {
|
||||
refreshLiveDetail();
|
||||
}, 15000);
|
||||
return () => clearInterval(timer);
|
||||
}, [id, league_id]);
|
||||
|
||||
const loadLiveDetail = async () => {
|
||||
try {
|
||||
setLoading(true);
|
||||
await refreshLiveDetail();
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
const refreshLiveDetail = async () => {
|
||||
try {
|
||||
// Fetch live scores for the league
|
||||
const sportId = parseInt(sport_id || "1");
|
||||
const leagueId = parseInt(league_id || "0");
|
||||
@@ -59,9 +74,7 @@ export default function LiveDetailScreen() {
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
} finally {
|
||||
setLoading(false);
|
||||
console.error("Refresh live detail error:", err);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -85,15 +98,18 @@ export default function LiveDetailScreen() {
|
||||
}
|
||||
|
||||
const renderTabContent = () => {
|
||||
const numericSportId = parseInt(sport_id || "1");
|
||||
switch (activeTab) {
|
||||
case "stats":
|
||||
return <StatsCard match={match} isDark={isDark} />;
|
||||
case "odds":
|
||||
return <OddsCard match={match} isDark={isDark} />;
|
||||
return (
|
||||
<OddsCard match={match} isDark={isDark} sportId={numericSportId} />
|
||||
);
|
||||
case "detail":
|
||||
return (
|
||||
<>
|
||||
<OddsCard match={match} isDark={isDark} />
|
||||
<OddsCard match={match} isDark={isDark} sportId={numericSportId} />
|
||||
<StatsCard match={match} isDark={isDark} />
|
||||
<EventsTimeline match={match} isDark={isDark} />
|
||||
<OtherInfoCard match={match} isDark={isDark} />
|
||||
|
||||
Reference in New Issue
Block a user