This commit is contained in:
parent
9f4019cb94
commit
a4e4e2a1ce
|
|
@ -24,26 +24,16 @@ export function WeatherSearchForm() {
|
|||
setInputError('请输入城市名称');
|
||||
return;
|
||||
}
|
||||
if (trimmedCity.length < 2) {
|
||||
if (trimmedCity.length <2) {
|
||||
setInputError('请输入至少2个字符');
|
||||
return;
|
||||
}
|
||||
if (!/^[a-zA-Z\s]+$/.test(trimmedCity)) {
|
||||
setInputError('请输入字母和空格');
|
||||
if (!/^[\u4e00-\u9fa5a-zA-Z\s-]+$/.test(trimmedCity)) {
|
||||
setInputError('请输入有效的城市名称');
|
||||
return;
|
||||
}
|
||||
await searchWeather(trimmedCity);
|
||||
|
||||
if (trimmedCity.length < 2) {
|
||||
setInputError('请输入至少2个字符');
|
||||
return;
|
||||
}
|
||||
|
||||
if (!/^[a-zA-Z\s]+$/.test(trimmedCity)) {
|
||||
setInputError('请输入字母和空格');
|
||||
return;
|
||||
}
|
||||
await searchWeather(trimmedCity);
|
||||
|
||||
}
|
||||
|
||||
return (
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
import React, {useEffect} from 'react';
|
||||
import { Loader2 } from 'lucide-react';
|
||||
import { WeatherCard } from '@/components/weather/WeatherCard';
|
||||
import { WeatherCard } from '@/components/WeatherCard';
|
||||
import { useWeatherStore } from '@/store/weatherStore';
|
||||
import {toast} from "sonner";
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue