Compare commits
2 Commits
e5f0512f05
...
9f4019cb94
| Author | SHA1 | Date |
|---|---|---|
|
|
9f4019cb94 | |
|
|
5bf049c66f |
|
|
@ -74,9 +74,6 @@ export function WeatherSearchForm() {
|
||||||
|
|
||||||
<div className='flex gap-2'>
|
<div className='flex gap-2'>
|
||||||
<Button type="submit" disabled={isLoading || !city.trim()} className="mt-4 w-full">
|
<Button type="submit" disabled={isLoading || !city.trim()} className="mt-4 w-full">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
{isLoading ? <>
|
{isLoading ? <>
|
||||||
<Loader2 className="animate-spin w-5 h-5 text-white" />
|
<Loader2 className="animate-spin w-5 h-5 text-white" />
|
||||||
<span>搜索中...</span>
|
<span>搜索中...</span>
|
||||||
|
|
@ -85,7 +82,6 @@ export function WeatherSearchForm() {
|
||||||
<span>搜索天气</span>
|
<span>搜索天气</span>
|
||||||
</>)}
|
</>)}
|
||||||
</Button>
|
</Button>
|
||||||
|
|
||||||
{currentWeather && (
|
{currentWeather && (
|
||||||
<Button type="button" variant="outline" onClick={refreshWeather} disabled={isLoading} className="mt-4 w-full" title='刷新数据'>
|
<Button type="button" variant="outline" onClick={refreshWeather} disabled={isLoading} className="mt-4 w-full" title='刷新数据'>
|
||||||
<RefreshCw className={cn("w-5 h-5", isLoading && "animate-spin")} />
|
<RefreshCw className={cn("w-5 h-5", isLoading && "animate-spin")} />
|
||||||
|
|
|
||||||
|
|
@ -89,7 +89,7 @@ export const useWeatherStore = create<WeatherStore>()(
|
||||||
return{weatherCache:newCache}
|
return{weatherCache:newCache}
|
||||||
}),
|
}),
|
||||||
setLoading:(loading)=>set({isLoading:loading}),
|
setLoading:(loading)=>set({isLoading:loading}),
|
||||||
setError:(error)=>set({error}),
|
setError:(error)=>set({error,isLoading:false}),
|
||||||
reset:()=>set({currentWeather:null,weatherCache:new Map(),isLoading:false,error:null}),
|
reset:()=>set({currentWeather:null,weatherCache:new Map(),isLoading:false,error:null}),
|
||||||
searchWeather:async(city:string)=>{
|
searchWeather:async(city:string)=>{
|
||||||
try{
|
try{
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue