From 1ee461ccd1030fc6ebad71b8e53ed89b4bbace27 Mon Sep 17 00:00:00 2001 From: qiuchenfan <2035024011@qq.com> Date: Mon, 17 Nov 2025 19:23:22 +0800 Subject: [PATCH] 111123 --- app/components/WeatherCard.tsx | 3 +++ app/components/WeatherSearchForm.tsx | 2 +- app/store/weatherStore.ts | 5 +++-- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/app/components/WeatherCard.tsx b/app/components/WeatherCard.tsx index 257cac9..3d92654 100644 --- a/app/components/WeatherCard.tsx +++ b/app/components/WeatherCard.tsx @@ -1,5 +1,8 @@ import { useWeatherStore } from "@/store/weatherStore"; import { Cloud } from "lucide-react"; +import {WeatherDisplay } from '@/components/WeatherDisplay' +import { WeatherSearchForm } from "./WeatherSearchForm"; +import { WeatherDetailsGrid } from "./WeatherDetailsGird"; export function WeatherCard(){ const{ currentWeather} = useWeatherStore(); diff --git a/app/components/WeatherSearchForm.tsx b/app/components/WeatherSearchForm.tsx index 04dff4f..8623d3c 100644 --- a/app/components/WeatherSearchForm.tsx +++ b/app/components/WeatherSearchForm.tsx @@ -7,7 +7,7 @@ import { useWeatherStore } from '@/store/weatherStore'; export function WeatherSearchForm() { - const [isLoading, currentWeather, searchWeather, refreshWeather] = useWeatherStore(); + const {isLoading, currentWeather, searchWeather, refreshWeather} = useWeatherStore(); const [city, setCity] = useState(''); const [inputError, setInputError] = useState(''); diff --git a/app/store/weatherStore.ts b/app/store/weatherStore.ts index 8754ff9..28d4ab0 100644 --- a/app/store/weatherStore.ts +++ b/app/store/weatherStore.ts @@ -1,5 +1,6 @@ import { create } from 'zustand' import {persist,createJSONStorage} from 'zustand/middleware' +import { WeatherApi } from '@/services/weatherApi'; const CACHE_EXPIRY = 10 * 60 * 1000; export interface Location { @@ -98,7 +99,7 @@ export const useWeatherStore = create()( set({currentWeather:cachedWeather,isLoading:false}); return; } - const WeatherData = await WeatherAPI.getcurrentWeather(city); + const WeatherData = await WeatherApi.getCurrentWeather(city); set({currentWeather:WeatherData,isLoading:false}); get().cacheWeather(city,WeatherData); }catch(error){ @@ -111,7 +112,7 @@ export const useWeatherStore = create()( try{ set({isLoading:true,error:null}); const city = currentWeather.location.name; - const WeatherData = await WeatherAPI.getcurrentWeather(city); + const WeatherData = await WeatherApi.getCurrentWeather(city); set({currentWeather:WeatherData,isLoading:false}); get().cacheWeather(city,WeatherData); }catch(error){