1
This commit is contained in:
@@ -243,11 +243,24 @@ const HomeNavbar = (props: IProps) => {
|
||||
|
||||
// 处理城市切换(用户手动选择)
|
||||
const handleCityChange = async (_newArea: any) => {
|
||||
// 用户手动选择的城市不保存到缓存
|
||||
// 用户手动选择的城市不保存到缓存(临时切换)
|
||||
console.log("用户手动选择城市(不保存缓存):", _newArea);
|
||||
|
||||
// 切换城市后,同时更新两个列表接口获取数据
|
||||
await handleCityChangeWithoutCache();
|
||||
// 先更新 area 状态(用于界面显示)
|
||||
updateArea(_newArea);
|
||||
|
||||
// 确保状态更新完成后再调用接口
|
||||
// 切换城市后,同时更新两个列表接口获取数据,传入新的城市信息
|
||||
const promises: Promise<any>[] = [];
|
||||
if (refreshBothLists) {
|
||||
promises.push(refreshBothLists(_newArea));
|
||||
}
|
||||
// 更新球局数量,直接传入新的城市信息,不依赖状态更新时序
|
||||
if (fetchGetGamesCount) {
|
||||
promises.push(fetchGetGamesCount(_newArea));
|
||||
}
|
||||
// 并行执行,提高性能
|
||||
await Promise.all(promises);
|
||||
};
|
||||
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user