fde6503bdf
Memind CI / Test, build, and release guards (push) Has been cancelled
Enable optional SEO/GEO injection and discovery routes for confirmed public pages while keeping private pages noindex. Add premium page template skills, portal catalog API, template shop UI, and Baidu push gated by memind_adm config. Co-authored-by: Cursor <cursoragent@cursor.com>
38 lines
1.0 KiB
TypeScript
38 lines
1.0 KiB
TypeScript
import { useEffect, useRef, useState } from 'react';
|
|
|
|
type TemplatePreviewThumbProps = {
|
|
previewUrl: string;
|
|
label: string;
|
|
};
|
|
|
|
export function TemplatePreviewThumb({ previewUrl, label }: TemplatePreviewThumbProps) {
|
|
const hostRef = useRef<HTMLSpanElement>(null);
|
|
const [visible, setVisible] = useState(false);
|
|
|
|
useEffect(() => {
|
|
const host = hostRef.current;
|
|
if (!host) return;
|
|
const observer = new IntersectionObserver(
|
|
([entry]) => {
|
|
if (entry?.isIntersecting) {
|
|
setVisible(true);
|
|
observer.disconnect();
|
|
}
|
|
},
|
|
{ rootMargin: '160px 0px' },
|
|
);
|
|
observer.observe(host);
|
|
return () => observer.disconnect();
|
|
}, [previewUrl]);
|
|
|
|
return (
|
|
<span ref={hostRef} className="template-shop-cell-thumb template-shop-cell-thumb-live">
|
|
{visible ? (
|
|
<iframe src={previewUrl} title={`${label} 预览缩略图`} tabIndex={-1} />
|
|
) : (
|
|
<span className="template-shop-thumb-placeholder" aria-hidden="true" />
|
|
)}
|
|
</span>
|
|
);
|
|
}
|