Merge branch 'main' of http://113.45.67.59:3003/lzq/test
This commit is contained in:
commit
39ac8592c3
|
|
@ -45,8 +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} />;
|
||||
}
|
||||
|
||||
|
||||
export function WeatherDisplay(){
|
||||
const {currentWeather} = useWeatherStore();
|
||||
if(!currentWeather) return null;
|
||||
|
|
|
|||
|
|
@ -8,10 +8,8 @@ import { useWeatherStore } from '@/store/weatherStore';
|
|||
|
||||
export function WeatherSearchForm() {
|
||||
const {isLoading, currentWeather, searchWeather, refreshWeather} = useWeatherStore();
|
||||
|
||||
const [city, setCity] = useState('');
|
||||
const [inputError, setInputError] = useState('');
|
||||
|
||||
const handleInputChange = (e: ChangeEvent<HTMLInputElement>) => {
|
||||
setCity(e.target.value);
|
||||
if (inputError) {
|
||||
|
|
@ -26,6 +24,15 @@ export function WeatherSearchForm() {
|
|||
setInputError('请输入城市名称');
|
||||
return;
|
||||
}
|
||||
if (trimmedCity.length < 2) {
|
||||
setInputError('请输入至少2个字符');
|
||||
return;
|
||||
}
|
||||
if (!/^[a-zA-Z\s]+$/.test(trimmedCity)) {
|
||||
setInputError('请输入字母和空格');
|
||||
return;
|
||||
}
|
||||
await searchWeather(trimmedCity);
|
||||
|
||||
if (trimmedCity.length < 2) {
|
||||
setInputError('请输入至少2个字符');
|
||||
|
|
|
|||
708
pnpm-lock.yaml
708
pnpm-lock.yaml
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue