ai-coding
2026-07-28 f0bd7b39769388460e4b635a78fe8270201f8ae5
refactor(robotaxi): 统一替换 Taro.showToast 为自定义 toast 组件1

Co-Authored-By: 甄雪君 <zhenxj@xiaopeng.com>
10个文件已修改
75 ■■■■■ 已修改文件
src/robotaxi/pages/coupon/index.tsx 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/robotaxi/pages/expense-description/index.tsx 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/robotaxi/pages/expense-detail/index.tsx 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/robotaxi/pages/favorite-sites/index.tsx 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/robotaxi/pages/order/detail/index.tsx 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/robotaxi/pages/order/index.tsx 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/robotaxi/pages/passenger-notice/index.tsx 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/robotaxi/pages/personal-center/index.tsx 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/robotaxi/pages/pricing-rules/index.tsx 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/robotaxi/pages/select-city/index.tsx 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/robotaxi/pages/coupon/index.tsx
@@ -10,6 +10,8 @@
  CouponDetail
} from "../../../robotaxi/api/coupon";
import { withRobotaxiWhitelist } from "../../../utils/whitelist";
import { showToast } from "../../components/toast";
import { withToast } from "../../components/toast/with-toast";
function CouponPage() {
  const [couponStatus] = useState([
@@ -144,7 +146,7 @@
      setVisible(true);
    } catch (error) {
      Taro.hideLoading();
      Taro.showToast({ title: "获取详情失败", icon: "none" });
      showToast({ title: "获取详情失败", icon: "none" });
    }
  };
@@ -162,12 +164,12 @@
    e.stopPropagation();
    try {
      await receiveCoupon({ couponId: item.couponId });
      Taro.showToast({ title: "领取成功", icon: "success" });
      showToast({ title: "领取成功", icon: "success" });
      // 领取成功后刷新列表
      getList(1, activeStatus, true);
      setPageNum(1);
    } catch (error) {
      Taro.showToast({ title: "领取失败", icon: "none" });
      showToast({ title: "领取失败", icon: "none" });
    }
  };
@@ -314,4 +316,4 @@
  );
}
export default withRobotaxiWhitelist(CouponPage);
export default withRobotaxiWhitelist(withToast(CouponPage));
src/robotaxi/pages/expense-description/index.tsx
@@ -8,6 +8,8 @@
} from '../../../utils/Robotaxi-public-method';
import EvaluatePopup from '../begin-route/components/evaluate-popup';
import { withRobotaxiWhitelist } from '../../../utils/whitelist';
import { showToast } from '../../components/toast';
import { withToast } from '../../components/toast/with-toast';
import './index.less';
function OrderPage() {
@@ -36,7 +38,7 @@
      setFareData(res);
    } catch (error) {
      console.error('获取费用明细失败', error);
      Taro.showToast({ title: '获取费用明细失败', icon: 'none' });
      showToast({ title: '获取费用明细失败', icon: 'none' });
    }
  };
@@ -274,4 +276,4 @@
  )
}
export default withRobotaxiWhitelist(OrderPage);
export default withRobotaxiWhitelist(withToast(OrderPage));
src/robotaxi/pages/expense-detail/index.tsx
@@ -7,6 +7,8 @@
  formatTripDurationFromSeconds
} from '../../../utils/Robotaxi-public-method';
import { withRobotaxiWhitelist } from '../../../utils/whitelist';
import { showToast } from '../../components/toast';
import { withToast } from '../../components/toast/with-toast';
/** 城市缓存 key */
const SELECTED_CITY_STORAGE_KEY = 'selectedCity';
@@ -56,7 +58,7 @@
    const cityID = getSelectedCityId();
    if (!cityID) {
      Taro.showToast({
      showToast({
        title: RESELECT_CITY_TOAST_TEXT,
        icon: 'none'
      });
@@ -189,4 +191,4 @@
  )
}
export default withRobotaxiWhitelist(OrderPage);
export default withRobotaxiWhitelist(withToast(OrderPage));
src/robotaxi/pages/favorite-sites/index.tsx
@@ -1,4 +1,4 @@
import Taro from '@tarojs/taro';
import Toast, { showToast } from '../../components/toast';
import { View, Image, ScrollView } from '@tarojs/components';
import { useEffect, useState } from 'react';
import './index.less';
@@ -55,10 +55,10 @@
      await collectPoint(payload);
      setList(prev => prev.filter(f => (f.id || f.pointId || f.stationId) !== (item.id || item.pointId || item.stationId)));
      Taro.showToast({ title: '已取消收藏', icon: 'none' });
      showToast({ title: '已取消收藏', icon: 'none' });
    } catch (e) {
      console.log('取消收藏失败', e);
      Taro.showToast({ title: '取消收藏失败', icon: 'none' });
      showToast({ title: '取消收藏失败', icon: 'none' });
    }
  };
@@ -97,6 +97,7 @@
          )}
        </View>
      </ScrollView>
      <Toast />
    </View>
  );
}
src/robotaxi/pages/order/detail/index.tsx
@@ -9,6 +9,8 @@
import { formatTripDistance, formatTripDurationFromSeconds, safeParse } from '../../../../utils/Robotaxi-public-method';
import { getOrderId } from '../../../utils/order';
import { withRobotaxiWhitelist } from '../../../../utils/whitelist';
import { showToast } from '../../../components/toast';
import { withToast } from '../../../components/toast/with-toast';
function OrderDetailPage() {
  const router = useRouter();
@@ -124,7 +126,7 @@
      setActiveIndex(res.orderRating);
    } catch (error) {
      console.error('获取订单详情失败', error);
      Taro.showToast({ title: '获取详情失败', icon: 'none' });
      showToast({ title: '获取详情失败', icon: 'none' });
    }
  };
@@ -249,7 +251,7 @@
  const submitSimpleEvaluate = (index: number) => {
    const targetOrderId = getOrderId(orderId);
    if (!targetOrderId) {
      Taro.showToast({ title: '订单信息缺失,无法提交评价', icon: 'none' });
      showToast({ title: '订单信息缺失,无法提交评价', icon: 'none' });
      return;
    }
    const successToastMap: Record<number, string> = {
@@ -260,13 +262,13 @@
    submitOrderComment({ orderRating: index, orderId: targetOrderId })
      .then(() => {
        setActiveIndex(index);
        Taro.showToast({
        showToast({
          title: successToastMap[index] || '评价提交成功',
          icon: 'none'
        });
      })
      .catch(() => {
        Taro.showToast({ title: '评价提交失败,请稍后重试', icon: 'none' });
        showToast({ title: '评价提交失败,请稍后重试', icon: 'none' });
      });
  }
@@ -386,4 +388,4 @@
  )
}
export default withRobotaxiWhitelist(OrderDetailPage);
export default withRobotaxiWhitelist(withToast(OrderDetailPage));
src/robotaxi/pages/order/index.tsx
@@ -32,6 +32,8 @@
const XP_INVOICE_APP_ID = "xp_invoice";
import { withRobotaxiWhitelist } from "../../../utils/whitelist";
import { showToast } from "../../components/toast";
import { withToast } from "../../components/toast/with-toast";
function OrderPage() {
  const router = useRouter();
@@ -183,7 +185,7 @@
  // 根据当前订单编号跳转到发票开具页面。
  const toInvoicePage = (orderNo?: string) => {
    if (!orderNo) {
      Taro.showToast({
      showToast({
        title: "订单编号缺失",
        icon: "none"
      });
@@ -368,4 +370,4 @@
  );
}
export default withRobotaxiWhitelist(OrderPage);
export default withRobotaxiWhitelist(withToast(OrderPage));
src/robotaxi/pages/passenger-notice/index.tsx
@@ -4,6 +4,8 @@
import './index.less'
import { getLoginAgreementContentInfo, getPrivacyContent } from '../../api/home';
import { withRobotaxiWhitelist } from '../../../utils/whitelist';
import { showToast } from '../../components/toast';
import { withToast } from '../../components/toast/with-toast';
type AgreementItem = {
  id: number | string;
@@ -56,9 +58,9 @@
        console.log('normalizeContent(target.content ||', normalizeContent(target.content || ''));
        return;
      }
      Taro.showToast({ title: '协议内容获取失败', icon: 'none' });
      showToast({ title: '协议内容获取失败', icon: 'none' });
    }).catch(() => {
      Taro.showToast({ title: '协议内容获取失败', icon: 'none' });
      showToast({ title: '协议内容获取失败', icon: 'none' });
    });
  }, []);
@@ -72,4 +74,4 @@
  )
}
export default withRobotaxiWhitelist(PassengerNotice);
export default withRobotaxiWhitelist(withToast(PassengerNotice));
src/robotaxi/pages/personal-center/index.tsx
@@ -39,6 +39,8 @@
];
import { withRobotaxiWhitelist } from '../../../utils/whitelist';
import { showToast } from '../../components/toast';
import { withToast } from '../../components/toast/with-toast';
function PersonalCenter() {
  const nickname = useSelector((state: any) => state.user?.userInfo?.nickName) || "小鹏艺术家";
@@ -137,7 +139,7 @@
      return;
    }
    Taro.showToast({ title: "功能建设中", icon: "none" });
    showToast({ title: "功能建设中", icon: "none" });
  };
  return (
@@ -218,4 +220,4 @@
  );
}
export default withRobotaxiWhitelist(PersonalCenter);
export default withRobotaxiWhitelist(withToast(PersonalCenter));
src/robotaxi/pages/pricing-rules/index.tsx
@@ -3,6 +3,8 @@
import { View, Text } from '@tarojs/components';
import { getPricingRules } from '../../api/pricing';
import { withRobotaxiWhitelist } from '../../../utils/whitelist';
import { showToast } from '../../components/toast';
import { withToast } from '../../components/toast/with-toast';
import './index.less';
type AnyRecord = Record<string, any>;
@@ -147,10 +149,10 @@
      setMockJson(res || {});
    } catch (error) {
      setMockJson({});
       Taro.showToast({
       showToast({
        title: '获取定价规则失败',
        icon: 'none'
      });
             });
    } finally {
      setLoading(false);
    }
@@ -584,5 +586,5 @@
  );
}
export default withRobotaxiWhitelist(PricingRulesPage);
export default withRobotaxiWhitelist(withToast(PricingRulesPage));
src/robotaxi/pages/select-city/index.tsx
@@ -4,6 +4,8 @@
import './index.less';
import { getOpenCity, getCityList } from '../../api/select-city';
import { withRobotaxiWhitelist } from '../../../utils/whitelist';
import { showToast } from '../../components/toast';
import { withToast } from '../../components/toast/with-toast';
@@ -103,7 +105,7 @@
  const handleSelectCity = (city, isOpen) => {
    if (!isOpen) {
      Taro.showToast({
      showToast({
        title: '该城市暂未开通服务',
        icon: 'none'
      });
@@ -295,4 +297,4 @@
  )
}
export default withRobotaxiWhitelist(SelectCityPage);
export default withRobotaxiWhitelist(withToast(SelectCityPage));