1
This commit is contained in:
@@ -66,6 +66,8 @@ const ListPageContent: React.FC<ListPageContentProps> = ({
|
||||
gamesNum, // 新增:获取球局数量
|
||||
} = store;
|
||||
|
||||
const supportedCitiesList = useDictionaryStore((s) => s.getDictionaryValue('supported_cities', ['上海市'])) || [];
|
||||
|
||||
const {
|
||||
isShowFilterPopup,
|
||||
data: matches,
|
||||
@@ -92,6 +94,8 @@ const ListPageContent: React.FC<ListPageContentProps> = ({
|
||||
// 记录上一次加载数据时的城市,用于检测城市变化
|
||||
const lastLoadedAreaRef = useRef<[string, string] | null>(null);
|
||||
const prevIsActiveRef = useRef(isActive);
|
||||
// 记录是否是进入列表页的第一次调用 updateUserLocation(首次传 force: true)
|
||||
const hasUpdatedLocationRef = useRef(false);
|
||||
|
||||
// 处理距离筛选显示/隐藏
|
||||
const handleDistanceFilterVisibleChange = useCallback(
|
||||
@@ -364,7 +368,10 @@ const ListPageContent: React.FC<ListPageContentProps> = ({
|
||||
updateState({ location });
|
||||
if (location && location.latitude && location.longitude) {
|
||||
try {
|
||||
await updateUserLocation(location.latitude, location.longitude);
|
||||
// 进入列表页的第一次调用传 force: true,后续调用传 false
|
||||
const isFirstCall = !hasUpdatedLocationRef.current;
|
||||
await updateUserLocation(location.latitude, location.longitude, isFirstCall);
|
||||
hasUpdatedLocationRef.current = true;
|
||||
} catch (error) {
|
||||
console.error("更新用户位置失败:", error);
|
||||
}
|
||||
@@ -476,7 +483,7 @@ const ListPageContent: React.FC<ListPageContentProps> = ({
|
||||
initDictionaryData();
|
||||
}, []);
|
||||
|
||||
// 获取省份名称(area 格式: ["中国", "省份"])
|
||||
|
||||
const province = area?.at(1) || "上海";
|
||||
|
||||
function renderCityQrcode() {
|
||||
@@ -518,8 +525,12 @@ const ListPageContent: React.FC<ListPageContentProps> = ({
|
||||
}
|
||||
|
||||
// 判定是否显示"暂无球局"页面
|
||||
// 条件:省份不是上海 或 (已加载完成且球局数量为0)
|
||||
const shouldShowNoGames = province !== "上海市";
|
||||
// 从配置接口 /parameter/many_key 获取 supported_cities(格式如 "上海市||北京市")
|
||||
// 当前省份在有球局城市列表中则显示列表,否则显示暂无球局
|
||||
const shouldShowNoGames =
|
||||
supportedCitiesList.length > 0
|
||||
? !supportedCitiesList.includes(province)
|
||||
: province !== "上海市"; // 配置未加载时默认按上海判断
|
||||
|
||||
return (
|
||||
<>
|
||||
|
||||
Reference in New Issue
Block a user