fix: load material previews from originals
This commit is contained in:
parent
291eb9b11c
commit
531a23d15f
@ -75,16 +75,14 @@ const MaterialImageCard = memo(function MaterialImageCard({
|
||||
onToggle: (imageId: string) => void;
|
||||
}) {
|
||||
const isPlaceholder = !String(image.imageUrl || "").trim();
|
||||
const previewUrl = String(image.previewUrl || "").trim();
|
||||
const displayImageUrl = previewUrl || String(image.imageUrl || "").trim();
|
||||
const fallbackImageUrl = previewUrl ? String(image.imageUrl || "").trim() : null;
|
||||
const displayImageUrl = String(image.imageUrl || "").trim();
|
||||
const [imageStatus, setImageStatus] = useState<"loading" | "loaded" | "error">(
|
||||
isPlaceholder ? "loaded" : "loading"
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
setImageStatus(isPlaceholder ? "loaded" : "loading");
|
||||
}, [displayImageUrl, fallbackImageUrl, isPlaceholder]);
|
||||
}, [displayImageUrl, isPlaceholder]);
|
||||
|
||||
return (
|
||||
<button
|
||||
@ -121,15 +119,12 @@ const MaterialImageCard = memo(function MaterialImageCard({
|
||||
) : (
|
||||
<AgentPreviewImage
|
||||
src={displayImageUrl}
|
||||
fallbackSrc={fallbackImageUrl}
|
||||
alt={image.label}
|
||||
className={cn(
|
||||
"h-full w-full object-contain transition-opacity duration-300",
|
||||
imageStatus === "loaded" ? "opacity-100" : "opacity-0"
|
||||
)}
|
||||
delivery="proxy"
|
||||
eager
|
||||
fallbackToOriginal={false}
|
||||
previewWidth={480}
|
||||
previewQuality={74}
|
||||
onError={() => {
|
||||
@ -146,12 +141,12 @@ const MaterialImageCard = memo(function MaterialImageCard({
|
||||
<Loader2 className="h-6 w-6 animate-spin text-emerald-200/80" />
|
||||
)}
|
||||
<div className="text-xs font-medium">
|
||||
{imageStatus === "error" ? "预览暂不可用" : "正在加载预览"}
|
||||
{imageStatus === "error" ? "原图暂不可用" : "正在加载原图"}
|
||||
</div>
|
||||
<div className="max-w-[180px] text-[11px] leading-5 text-white/45">
|
||||
{imageStatus === "error"
|
||||
? "原图地址仍可用于后续生成,可先选中或稍后重试。"
|
||||
: "已命中素材,正在拉取缩略预览。"}
|
||||
? "原图地址返回异常,可先稍后重试或联系素材服务检查。"
|
||||
: "已命中素材,正在直接拉取原图。"}
|
||||
</div>
|
||||
</div>
|
||||
) : null}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user