This commit is contained in:
Li1304553726 2025-11-17 19:31:25 +08:00
commit bfeea2dc3f
3 changed files with 11 additions and 14 deletions

View File

@ -1,5 +1,6 @@
import { Cloud, Droplets, Gauge, ThermometerSun, Wind } from "lucide-react"; import { Cloud, Droplets, Gauge, ThermometerSun, Wind } from "lucide-react";
import { useWeatherStore } from "@/store/weatherStore"; import { useWeatherStore } from "@/store/weatherStore";
import { MapPin, Thermometer } from "lucide-react";
interface WeatherDetailsGridProps { interface WeatherDetailsGridProps {
icon: React.ReactNode; icon: React.ReactNode;

View File

@ -9,6 +9,7 @@ import {
CloudSnow, CloudSnow,
CloudSun, CloudSun,
MapPin, Moon, Sun, MapPin, Moon, Sun,
Thermometer,
ThermometerSun ThermometerSun
} from 'lucide-react'; } from 'lucide-react';
@ -44,7 +45,6 @@ function WeatherIcon({ description, isDay, className = "w-16 h-16 md:w-20 md:h-2
} }
return isDaytime ? <Sun className={className} /> : <Moon className={className} />; return isDaytime ? <Sun className={className} /> : <Moon className={className} />;
} }
export function WeatherDisplay(){ export function WeatherDisplay(){
const {currentWeather} = useWeatherStore(); const {currentWeather} = useWeatherStore();
if(!currentWeather) return null; if(!currentWeather) return null;

View File

@ -25,11 +25,7 @@ export function WeatherSearchForm() {
setInputError('请输入城市名称'); setInputError('请输入城市名称');
return; return;
} }
if (!trimmedCity) {
setInputError('请输入有效的城市名称');
return;
}
if (trimmedCity.length < 2) { if (trimmedCity.length < 2) {
setInputError('请输入至少2个字符'); setInputError('请输入至少2个字符');
return; return;
@ -40,10 +36,9 @@ export function WeatherSearchForm() {
return; return;
} }
await searchWeather(trimmedCity); await searchWeather(trimmedCity);
}
return ( return (
<div className='p-6 border-6 '> <div className='p-6 border-6 border-b-slate-200/50 '>
<form onSubmit={handleFormSubmit} className="space-by-3"> <form onSubmit={handleFormSubmit} className="space-by-3">
<div className="relative"> <div className="relative">
<div className="absolute inset-y-0 left-4 flex items-center pl-3 pointer-events-none"> <div className="absolute inset-y-0 left-4 flex items-center pl-3 pointer-events-none">
@ -52,16 +47,16 @@ export function WeatherSearchForm() {
<Input <Input
type="text" type="text"
value={city} value={city}
onChange={(e) => setCity(e.target.value)} onChange={handleInputChange}
placeholder="请输入城市名称" placeholder="请输入城市名称"
disabled={isLoading} disabled={isLoading}
className={cn('pl-10 pr-4 py-2 w-full', inputError && 'border-red-500')} className={cn('pl-10 pr-4 py-2 w-full text-base rounded-xl bg-slate-50/50 focus:bg-white transition-all', inputError && 'border-red-500') }
/> />
</div> </div>
{inputError && ( {inputError && (
<div className="text-red-500 text-sm mt-1"> <div className=" flex items-center gap-2 px-3 py-2 rounded-lg bg-red-50/80 animated-in slide-in-from-top-1 fade-in">
<AlertCircle className="inline w-4 h-4 mr-1" /> <AlertCircle className="inline w-4 h-4 text-red-500 mt-0.5" />
<p className="inline-block">{inputError}</p> <p className="text-red-500 text-xs">{inputError}</p>
</div> </div>
@ -99,4 +94,5 @@ export function WeatherSearchForm() {
) )
} }
}
} }