ai-coding
2026-07-27 6b5c3827d7b5fbada6788ce8e71ea1ee93bdbfc9
fix(city-switch): 使用当前城市code作为初始基准值以正确触发切城逻辑

Co-Authored-By: 廖芳 <liaof@xiaopeng.com>
2个文件已修改
7 ■■■■■ 已修改文件
src/pages/robotaxi/home/hooks/use-city-switch.ts 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/pages/robotaxi/home/index.tsx 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/pages/robotaxi/home/hooks/use-city-switch.ts
@@ -12,7 +12,7 @@
  setIsAdsorbed: (value: boolean) => void;
};
export default function useCitySwitch() {
export default function useCitySwitch(currentSelectedCityCode?: string) {
  /** 跳过下次定位居中 */
  const skipNextLocationCenterRef = useRef(false);
  /** 跳过 selectedCity 变更副作用 */
@@ -36,7 +36,8 @@
      return null;
    }
    const nextCode = selectedCity.code;
    if (lastSelectedCityCodeRef.current && nextCode && lastSelectedCityCodeRef.current !== nextCode) {
    const previousCode = lastSelectedCityCodeRef.current || currentSelectedCityCode;
    if (previousCode && nextCode && previousCode !== nextCode) {
      isCitySwitchingRef.current = true;
      shouldMoveToSwitchedCityCenterRef.current = true;
      Taro.removeStorageSync('startSite');
src/pages/robotaxi/home/index.tsx
@@ -192,7 +192,7 @@
    lastSelectedCityCodeRef,
    syncSelectedCityFromStorage,
    consumeCitySwitchFlag
  } = useCitySwitch();
  } = useCitySwitch(selectedCity?.code);
  const { displayPolygons, handleScaleChange } = useStationScaleFocus({
    currentSite: siteState.currentSite,
    originalPolygons: mapState.polygons