diff --git a/1114/app/components/weather/WeatherCard.tsx b/1114/app/components/weather/WeatherCard.tsx index e69de29..732f1d7 100644 --- a/1114/app/components/weather/WeatherCard.tsx +++ b/1114/app/components/weather/WeatherCard.tsx @@ -0,0 +1,33 @@ +import { WeathersearchForm } from "./WeatherSearchForm.tsx"; +import { WeatherDisplay } from "./WeatherDisplay.tsx"; +import { WeatherDetailsGrid } from "./WeatherDetailsGrid.tsx"; +import { useWeatherStore } from "./WeatherStore.tsx"; +import Cloud from "../../../assets/cloud.svg"; + +export function WeatherCard() { + const { currentWeather } = useWeatherStore(); + + return ( +
+ + {currentWeather ? ( +
+ + +
+ ) : ( +
+
+
+
+ +
+
+

暂无天气数据

+

请搜索城市查看实时天气信息

+
+ + )} +
+ ); +} diff --git a/1114/app/routes/weather.tsx b/1114/app/routes/weather.tsx index e69de29..9a3823f 100644 --- a/1114/app/routes/weather.tsx +++ b/1114/app/routes/weather.tsx @@ -0,0 +1,55 @@ +import REACT, { use, useEffect } from 'react' +import { Loader2 } from 'lucide-react'; +import { WeatherCard } from './WeatherCard' +import { useWeatherstore } from './WeatherStore' +import { toast } from 'sonner' + + + +export function meta() { + return [ + { title: "天气查询页面" }, + { name: "description", content: "查询天气信息" } + ] + +} + +export default function Weather() { + const { currentWeather, isLoading, error, seterror } = useWeatherstore() + useEffect(() => { + if (error) { + toast.error(error) + seterror("") + } + }, [error, seterror]) + + return ( +
+
+
+

天气查询

+

实时天气

+
+ {isLoading && !currentWeather && ( +
+
+
+
+
+
+ +
+
+

加载中...

+
+
+ )} + {!isLoading || currentWeather ? ( +
+ +
+ ) : null} +
+
+ ) +} \ No newline at end of file