From 3b8cff73239248735ee223fecab79b7ee6778f34 Mon Sep 17 00:00:00 2001 From: jinsir <874871581@qq.com> Date: Fri, 14 Nov 2025 18:51:33 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E6=96=B0=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 1114/app/components/weather/WeatherCard.tsx | 10 +++++----- 1114/app/routes/weather.tsx | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/1114/app/components/weather/WeatherCard.tsx b/1114/app/components/weather/WeatherCard.tsx index 732f1d7..1d594f7 100644 --- a/1114/app/components/weather/WeatherCard.tsx +++ b/1114/app/components/weather/WeatherCard.tsx @@ -1,7 +1,7 @@ -import { WeathersearchForm } from "./WeatherSearchForm.tsx"; -import { WeatherDisplay } from "./WeatherDisplay.tsx"; -import { WeatherDetailsGrid } from "./WeatherDetailsGrid.tsx"; -import { useWeatherStore } from "./WeatherStore.tsx"; +import { WeatherSearchForm } from "@/components/weather/WeatherSearchForm.tsx"; +import { WeatherDisplay } from "@/components/weather/WeatherDisplay.tsx"; +import { WeatherDetailsGrid } from "@/components/weather/WeatherDetailsGrid.tsx"; +import { useWeatherStore } from "@/store/weatherStore.tsx"; import Cloud from "../../../assets/cloud.svg"; export function WeatherCard() { @@ -9,7 +9,7 @@ export function WeatherCard() { return (
- + {currentWeather ? (
diff --git a/1114/app/routes/weather.tsx b/1114/app/routes/weather.tsx index 9a3823f..0592099 100644 --- a/1114/app/routes/weather.tsx +++ b/1114/app/routes/weather.tsx @@ -1,7 +1,7 @@ import REACT, { use, useEffect } from 'react' import { Loader2 } from 'lucide-react'; -import { WeatherCard } from './WeatherCard' -import { useWeatherstore } from './WeatherStore' +import { WeatherCard } from '@/components/weather/WeatherCard' +import { useWeatherStore } from '@/store/weatherStore' import { toast } from 'sonner' @@ -15,13 +15,13 @@ export function meta() { } export default function Weather() { - const { currentWeather, isLoading, error, seterror } = useWeatherstore() + const { currentWeather, isLoading, error, setError } = useWeatherStore() useEffect(() => { if (error) { toast.error(error) - seterror("") + setError("") } - }, [error, seterror]) + }, [error, setError]) return (
From 8b94b16caab33304718a2715ed87327382c46e11 Mon Sep 17 00:00:00 2001 From: qiuchenfan <2035024011@qq.com> Date: Fri, 14 Nov 2025 19:07:37 +0800 Subject: [PATCH 2/2] 222 --- 1114/app/components/weather/WeatherCard.tsx | 6 +++--- .../{WeatherDetailsCrid.tsx => WeatherDetailsGrid.tsx} | 5 ++++- 1114/app/components/weather/WeatherSearchForm.tsx | 4 ++-- 1114/app/routes/weather.tsx | 10 +++++----- 1114/app/services/weatherApi.ts | 2 +- 5 files changed, 15 insertions(+), 12 deletions(-) rename 1114/app/components/weather/{WeatherDetailsCrid.tsx => WeatherDetailsGrid.tsx} (94%) diff --git a/1114/app/components/weather/WeatherCard.tsx b/1114/app/components/weather/WeatherCard.tsx index a44ccc8..1f8b3af 100644 --- a/1114/app/components/weather/WeatherCard.tsx +++ b/1114/app/components/weather/WeatherCard.tsx @@ -1,6 +1,6 @@ -import { WeathersearchForm } from "@/components/weather/WeatherSearchForm"; +import { WeatherSearchForm } from "@/components/weather/WeatherSearchForm"; import { WeatherDisplay } from "@/components/weather/WeatherDisplay"; -import { WeatherDetailsGrid } from "@/components/weather/WeatherDetailsCrid"; +import { WeatherDetailsGrid } from "@/components/weather/WeatherDetailsGrid"; import { useWeatherStore } from "@/store/weatherStore"; import Cloud from "../../../assets/cloud.svg"; @@ -9,7 +9,7 @@ export function WeatherCard() { return (
- + {currentWeather ? (
diff --git a/1114/app/components/weather/WeatherDetailsCrid.tsx b/1114/app/components/weather/WeatherDetailsGrid.tsx similarity index 94% rename from 1114/app/components/weather/WeatherDetailsCrid.tsx rename to 1114/app/components/weather/WeatherDetailsGrid.tsx index 837db65..d3cbb85 100644 --- a/1114/app/components/weather/WeatherDetailsCrid.tsx +++ b/1114/app/components/weather/WeatherDetailsGrid.tsx @@ -10,7 +10,8 @@ interface WeatherInfoItemProps { subtitle?: string; } -function WeatherInfoItem({ icon, label, value, subtitle }: WeatherInfoItemProps) { +export function WeatherInfoItem({ icon, label, value, subtitle }: WeatherInfoItemProps) { + return (
@@ -28,6 +29,8 @@ function WeatherInfoItem({ icon, label, value, subtitle }: WeatherInfoItemProps) export function WeatherDetailsGrid() { + const {currentWeather} = useWeatherStore(); + if (!currentWeather) return null; <>
{ if (error) { toast.error(error) - seterror("") + setError("") } - }, [error, seterror]) + }, [error, setError]) return (
diff --git a/1114/app/services/weatherApi.ts b/1114/app/services/weatherApi.ts index e40a53a..0f2a275 100644 --- a/1114/app/services/weatherApi.ts +++ b/1114/app/services/weatherApi.ts @@ -1,5 +1,5 @@ import axios, {type AxiosInstance,AxiosError} from 'axios'; -import {WeatherData} from "@/store/weatherStore"; +import {type WeatherData} from "@/store/weatherStore"; //配置常量 const API_KEY = '5097cc3212ea9c460b01e2be936c94d5';