From fc449357bd3aa2e33621b45033e67246052957c8 Mon Sep 17 00:00:00 2001 From: qiuchenfan <2035024011@qq.com> Date: Mon, 17 Nov 2025 19:50:08 +0800 Subject: [PATCH] 11171950 --- app/routes/weather.tsx | 103 ++++++++++++++++++++++++----------------- 1 file changed, 60 insertions(+), 43 deletions(-) diff --git a/app/routes/weather.tsx b/app/routes/weather.tsx index bf7860f..c8ce90a 100644 --- a/app/routes/weather.tsx +++ b/app/routes/weather.tsx @@ -1,49 +1,66 @@ -import { toast } from "sonner" -import { Loader2 } from "lucide-react" -import { useEffect } from "react" -import { useWeatherStore } from "../store/weatherStore" -import { WeatherCard } from "@/components/WeatherCard" + + +import React, {useEffect} from 'react'; +import { Loader2 } from 'lucide-react'; +import { WeatherCard } from '@/components/weather/WeatherCard'; +import { useWeatherStore } from '@/store/weatherStore'; +import {toast} from "sonner"; + export function meta() { - return [ - { title: "天气查询页面" }, - { name: "description", content: "查询天气信息" } - ] + return [ + { title: '天气 - Apple风格设计' }, + { name: 'description', content: '优雅的天气查询应用' }, + ]; } -export function Weather() { - const { currentWeather, isLoading, error, setError } = useWeatherStore() + + +export default function Weather() { + const { currentWeather, isLoading ,error,setError} = useWeatherStore(); + // Show toast when error changes useEffect(() => { if (error) { - toast.error(error) - setError("") + toast.error(error); + // Clear error after showing toast + setError(null); } - }, [ErrorEvent, setError]) - return ( -
-
-
-

天气查询

-

实时天气

-
- {isLoading && !currentWeather && ( -
-
-
-
-
-
- -
-
-

正在加载...

-
- ) - } - {isLoading || currentWeather ? ( -
- -
- ) : null} + }, [error, setError]); + return ( +
+
+ +
+

+ 天气 +

+

+ 实时天气信息 +

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

+ 正在获取天气数据 +

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