接口添加时间与时区&赔率
This commit is contained in:
@@ -34,6 +34,15 @@ export default function HomeScreen() {
|
||||
const [loadingLeagues, setLoadingLeagues] = useState(false);
|
||||
const [now, setNow] = useState(() => new Date());
|
||||
|
||||
const deviceTimeZone = useMemo(() => {
|
||||
try {
|
||||
console.log("deviceTimeZone", Intl.DateTimeFormat().resolvedOptions().timeZone);
|
||||
return Intl.DateTimeFormat().resolvedOptions().timeZone || "UTC";
|
||||
} catch {
|
||||
return "UTC";
|
||||
}
|
||||
}, []);
|
||||
|
||||
// Selection States
|
||||
// 默认足球
|
||||
const [selectedSportId, setSelectedSportId] = useState<number | null>(1);
|
||||
@@ -158,7 +167,7 @@ export default function HomeScreen() {
|
||||
const loadMatches = async (sportId: number) => {
|
||||
setLoading(true);
|
||||
try {
|
||||
const list = await fetchTodayMatches(sportId, selectedDate);
|
||||
const list = await fetchTodayMatches(sportId, selectedDate, deviceTimeZone);
|
||||
setMatches(list);
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
|
||||
@@ -10,7 +10,7 @@ import { Colors } from "@/constants/theme";
|
||||
import { useTheme } from "@/context/ThemeContext";
|
||||
import { fetchLeagues, fetchSports, fetchTodayMatches } from "@/lib/api";
|
||||
import { League, Match, Sport } from "@/types/api";
|
||||
import React, { useEffect, useState } from "react";
|
||||
import React, { useEffect, useMemo, useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import {
|
||||
ActivityIndicator,
|
||||
@@ -32,6 +32,14 @@ export default function HomeScreen() {
|
||||
const [matches, setMatches] = useState<Match[]>([]);
|
||||
const [loading, setLoading] = useState(true);
|
||||
|
||||
const deviceTimeZone = useMemo(() => {
|
||||
try {
|
||||
return Intl.DateTimeFormat().resolvedOptions().timeZone || "UTC";
|
||||
} catch {
|
||||
return "UTC";
|
||||
}
|
||||
}, []);
|
||||
|
||||
// Selection States
|
||||
// 默认足球
|
||||
const [selectedSportId, setSelectedSportId] = useState<number | null>(1);
|
||||
@@ -131,7 +139,7 @@ export default function HomeScreen() {
|
||||
setLoading(true);
|
||||
try {
|
||||
// Pass selectedDate if API supported it
|
||||
const list = await fetchTodayMatches(sportId);
|
||||
const list = await fetchTodayMatches(sportId, undefined, deviceTimeZone);
|
||||
setMatches(list);
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
|
||||
@@ -7,6 +7,7 @@ import { SubstitutesCard } from "@/components/match-detail/football/substitutes-
|
||||
import { LeagueInfo } from "@/components/match-detail/league-info";
|
||||
import { MatchInfoCard } from "@/components/match-detail/match-info-card";
|
||||
import { MatchTabs } from "@/components/match-detail/match-tabs";
|
||||
import { OddsView } from "@/components/match-detail/odds/odds-view";
|
||||
import { ScoreHeader } from "@/components/match-detail/score-header";
|
||||
import { ThemedText } from "@/components/themed-text";
|
||||
import { ThemedView } from "@/components/themed-view";
|
||||
@@ -160,13 +161,7 @@ export default function MatchDetailScreen() {
|
||||
);
|
||||
}
|
||||
case "odds":
|
||||
return (
|
||||
<View style={styles.emptyContent}>
|
||||
<ThemedText style={styles.emptyText}>
|
||||
{t("detail.empty_odds")}
|
||||
</ThemedText>
|
||||
</View>
|
||||
);
|
||||
return <OddsView sportId={sportId} matchId={data.match.ID} />;
|
||||
case "h2h":
|
||||
return (
|
||||
<View style={styles.emptyContent}>
|
||||
|
||||
Reference in New Issue
Block a user