import { cn, getBackgroundImage, getStaticImage } from "@/lib/utils"; // 原始尺寸(保持比例) const ORIGINAL_SIZES = { read: { width: 116, height: 140 }, unread: { width: 120, height: 121 }, } as const; const Cursor = ({ className, onClick, read = false, size = 1, }: { className?: string; onClick: () => void; /** 已阅读 / 已完成 状态;true 时显示预留的 div,由你自行实现效果 */ read?: boolean; /** 尺寸缩放比例,默认为 1(原始大小) */ size?: number; }) => { // 根据 size 计算实际尺寸,保持原始比例 const baseSize = read ? ORIGINAL_SIZES.read : ORIGINAL_SIZES.unread; const width = baseSize.width * size; const height = baseSize.height * size; return (
{ e.preventDefault(); // 防止 Safari 触发两次 onClick(); }} style={{ width: `${width}px`, height: `${height}px`, WebkitTapHighlightColor: "transparent", WebkitTouchCallout: "none", WebkitUserSelect: "none", touchAction: "manipulation", backgroundImage: getBackgroundImage( read ? "components/point_" : "components/border" ), backgroundSize: "contain", backgroundPosition: "center", backgroundRepeat: "no-repeat", }} onClick={onClick} draggable={false} > {read ? ( // 已阅读 / 已完成 状态 //
// 已浏览 //
<> ) : ( // 未阅读 / 未完成 状态:保持当前效果 )}
); }; export default Cursor;