import React from 'react'; import { Badge } from "@nutui/nutui-react-taro"; import { Cart } from "@nutui/icons-react-taro"; import { useCart } from "@/hooks/useCart"; import { switchTab } from '@/utils/navigation'; interface CartIconProps { style?: React.CSSProperties; className?: string; size?: number; showBadge?: boolean; onClick?: () => void; } const CartIcon: React.FC = ({ style, className = '', size = 16, showBadge = true, onClick }) => { const { cartCount } = useCart(); const handleClick = () => { if (onClick) { onClick(); } else { // 默认跳转到购物车页面 switchTab('cart/cart'); } }; if (showBadge) { return (
); } return (
); }; export default CartIcon;