From 5e3853b753c317c6c5edc914779239578f0c9b51 Mon Sep 17 00:00:00 2001 From: qiuchenfan <2035024011@qq.com> Date: Mon, 17 Nov 2025 19:18:46 +0800 Subject: [PATCH 1/5] 11171918 --- app/components/WeatherDisplay.tsx | 46 +++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 app/components/WeatherDisplay.tsx diff --git a/app/components/WeatherDisplay.tsx b/app/components/WeatherDisplay.tsx new file mode 100644 index 0000000..6efd581 --- /dev/null +++ b/app/components/WeatherDisplay.tsx @@ -0,0 +1,46 @@ + +import React from 'react'; +import { + Cloud, + CloudDrizzle, + CloudFog, + CloudLightning, CloudMoon, + CloudRain, + CloudSnow, + CloudSun, + MapPin, Moon, Sun, + ThermometerSun +} from 'lucide-react'; + +import { formatTemperature } from "@/lib/utils"; +import { useWeatherStore } from '@/store/weatherStore'; +interface WeatherIconProps { + description: string; + isDay: string; + className?: string; +} + +/** + * Returns the appropriate weather icon based on description and time of day + */ +function WeatherIcon({ description, isDay, className = "w-16 h-16 md:w-20 md:h-20" }: WeatherIconProps) { + const desc = description.toLowerCase(); + const isDaytime = isDay === 'yes'; + + if (desc.includes('rain') || desc.includes('雨')) { + return desc.includes('heavy') || desc.includes('暴') + ? + : ; + } + if (desc.includes('snow') || desc.includes('雪')) return ; + if (desc.includes('thunder') || desc.includes('storm') || desc.includes('雷')) return ; + if (desc.includes('fog') || desc.includes('mist') || desc.includes('haze') || desc.includes('雾') || desc.includes('霾')) return ; + if (desc.includes('partly') || desc.includes('scattered') || desc.includes('多云')) { + return isDaytime ? : ; + } + if (desc.includes('cloudy') || desc.includes('overcast') || desc.includes('阴')) return ; + if (desc.includes('clear') || desc.includes('sunny') || desc.includes('晴')) { + return isDaytime ? : ; + } + return isDaytime ? : ; +} 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 2/5] 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){ From 85994055eddcece1b362b6fdcba479a7b243ce2f Mon Sep 17 00:00:00 2001 From: Li1304553726 <1304553726@qq.com> Date: Mon, 17 Nov 2025 19:23:58 +0800 Subject: [PATCH 3/5] 1 --- app/components/WeatherDispaly2.tsx | 45 ++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 app/components/WeatherDispaly2.tsx diff --git a/app/components/WeatherDispaly2.tsx b/app/components/WeatherDispaly2.tsx new file mode 100644 index 0000000..b519075 --- /dev/null +++ b/app/components/WeatherDispaly2.tsx @@ -0,0 +1,45 @@ +import { MapPin, Thermometer } from "lucide-react"; + +export function WeatherDisplay2(){ + const {currentWeather} = useWeatherStore(); + if(!currentWeather) return null; + + return( +
+
+
+
+
+
+

{currentWeather.location.name}

+
+ + {currentWeather.location.country} +
+
+ +
+
+
+ + {formatTemperature(currentWeather.current.temperature)} + + + °C + +
+

+ {currentWeather.current.weather_descriptions[0]} +

+
+ + 体感{formatTemperature(currentWeather.current.feelslike)}°C +
+
+
+
+ ) +} \ No newline at end of file From 93b467ba13b543dbce009f146b413ea492863a23 Mon Sep 17 00:00:00 2001 From: qiuchenfan <2035024011@qq.com> Date: Mon, 17 Nov 2025 19:26:09 +0800 Subject: [PATCH 4/5] 1114 --- app/components/WeatherDetailsGird.tsx | 1 + app/components/WeatherDispaly2.tsx | 45 -------------------------- app/components/WeatherDisplay.tsx | 46 +++++++++++++++++++++++++++ 3 files changed, 47 insertions(+), 45 deletions(-) delete mode 100644 app/components/WeatherDispaly2.tsx diff --git a/app/components/WeatherDetailsGird.tsx b/app/components/WeatherDetailsGird.tsx index 30bf498..d4fe5ff 100644 --- a/app/components/WeatherDetailsGird.tsx +++ b/app/components/WeatherDetailsGird.tsx @@ -1,5 +1,6 @@ import { Cloud, Droplets, Gauge, ThermometerSun, Wind } from "lucide-react"; import { useWeatherStore } from "@/store/weatherStore"; +import { MapPin, Thermometer } from "lucide-react"; interface WeatherDetailsGridProps { icon: React.ReactNode; diff --git a/app/components/WeatherDispaly2.tsx b/app/components/WeatherDispaly2.tsx deleted file mode 100644 index b519075..0000000 --- a/app/components/WeatherDispaly2.tsx +++ /dev/null @@ -1,45 +0,0 @@ -import { MapPin, Thermometer } from "lucide-react"; - -export function WeatherDisplay2(){ - const {currentWeather} = useWeatherStore(); - if(!currentWeather) return null; - - return( -
-
-
-
-
-
-

{currentWeather.location.name}

-
- - {currentWeather.location.country} -
-
- -
-
-
- - {formatTemperature(currentWeather.current.temperature)} - - - °C - -
-

- {currentWeather.current.weather_descriptions[0]} -

-
- - 体感{formatTemperature(currentWeather.current.feelslike)}°C -
-
-
-
- ) -} \ No newline at end of file diff --git a/app/components/WeatherDisplay.tsx b/app/components/WeatherDisplay.tsx index 6efd581..c6e3415 100644 --- a/app/components/WeatherDisplay.tsx +++ b/app/components/WeatherDisplay.tsx @@ -9,6 +9,7 @@ import { CloudSnow, CloudSun, MapPin, Moon, Sun, + Thermometer, ThermometerSun } from 'lucide-react'; @@ -44,3 +45,48 @@ function WeatherIcon({ description, isDay, className = "w-16 h-16 md:w-20 md:h-2 } return isDaytime ? : ; } + + +export function WeatherDisplay2(){ + const {currentWeather} = useWeatherStore(); + if(!currentWeather) return null; + + return( +
+
+
+
+
+
+

{currentWeather.location.name}

+
+ + {currentWeather.location.country} +
+
+ +
+
+
+ + {formatTemperature(currentWeather.current.temperature)} + + + °C + +
+

+ {currentWeather.current.weather_descriptions[0]} +

+
+ + 体感{formatTemperature(currentWeather.current.feelslike)}°C +
+
+
+
+ ) +} \ No newline at end of file From 56c08f7c8f54498d09badeebc287b3df99f9e664 Mon Sep 17 00:00:00 2001 From: qiuchenfan <2035024011@qq.com> Date: Mon, 17 Nov 2025 19:29:17 +0800 Subject: [PATCH 5/5] 1115 --- app/components/WeatherDisplay.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/components/WeatherDisplay.tsx b/app/components/WeatherDisplay.tsx index c6e3415..33e8b7a 100644 --- a/app/components/WeatherDisplay.tsx +++ b/app/components/WeatherDisplay.tsx @@ -47,7 +47,7 @@ function WeatherIcon({ description, isDay, className = "w-16 h-16 md:w-20 md:h-2 } -export function WeatherDisplay2(){ +export function WeatherDisplay(){ const {currentWeather} = useWeatherStore(); if(!currentWeather) return null; @@ -82,7 +82,7 @@ export function WeatherDisplay2(){ {currentWeather.current.weather_descriptions[0]}

- + 体感{formatTemperature(currentWeather.current.feelslike)}°C