添加角球设置功能,更新状态管理和界面显示逻辑
This commit is contained in:
@@ -1,4 +1,9 @@
|
||||
import { CardsSettings, OddsSettings, storage } from "@/lib/storage";
|
||||
import {
|
||||
CardsSettings,
|
||||
CornerSettings,
|
||||
OddsSettings,
|
||||
storage,
|
||||
} from "@/lib/storage";
|
||||
import React, {
|
||||
createContext,
|
||||
ReactNode,
|
||||
@@ -14,6 +19,7 @@ interface AppState {
|
||||
timezone: string;
|
||||
oddsSettings: OddsSettings;
|
||||
cardsSettings: CardsSettings;
|
||||
cornerSettings: CornerSettings;
|
||||
}
|
||||
|
||||
interface AppStateContextType {
|
||||
@@ -24,6 +30,7 @@ interface AppStateContextType {
|
||||
updateTimezone: (timezone: string) => void;
|
||||
updateOddsSettings: (settings: OddsSettings) => void;
|
||||
updateCardsSettings: (settings: CardsSettings) => void;
|
||||
updateCornerSettings: (settings: CornerSettings) => void;
|
||||
}
|
||||
|
||||
const AppStateContext = createContext<AppStateContextType | undefined>(
|
||||
@@ -38,6 +45,7 @@ export function AppStateProvider({ children }: { children: ReactNode }) {
|
||||
timezone: "UTC",
|
||||
oddsSettings: { enabled: false, selectedBookmakers: [] },
|
||||
cardsSettings: { enabled: false },
|
||||
cornerSettings: { enabled: false },
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
@@ -48,6 +56,9 @@ export function AppStateProvider({ children }: { children: ReactNode }) {
|
||||
storage.getCardsSettings().then((settings) => {
|
||||
setState((prev) => ({ ...prev, cardsSettings: settings }));
|
||||
});
|
||||
storage.getCornerSettings().then((settings) => {
|
||||
setState((prev) => ({ ...prev, cornerSettings: settings }));
|
||||
});
|
||||
}, []);
|
||||
|
||||
const updateSportId = (sportId: number | null) => {
|
||||
@@ -76,6 +87,11 @@ export function AppStateProvider({ children }: { children: ReactNode }) {
|
||||
storage.setCardsSettings(settings);
|
||||
};
|
||||
|
||||
const updateCornerSettings = (settings: CornerSettings) => {
|
||||
setState((prev) => ({ ...prev, cornerSettings: settings }));
|
||||
storage.setCornerSettings(settings);
|
||||
};
|
||||
|
||||
return (
|
||||
<AppStateContext.Provider
|
||||
value={{
|
||||
@@ -86,6 +102,7 @@ export function AppStateProvider({ children }: { children: ReactNode }) {
|
||||
updateTimezone,
|
||||
updateOddsSettings,
|
||||
updateCardsSettings,
|
||||
updateCornerSettings,
|
||||
}}
|
||||
>
|
||||
{children}
|
||||
|
||||
Reference in New Issue
Block a user