fix: stop agent generation workspace render loop
This commit is contained in:
parent
8a34cd4570
commit
2a2d4f46b3
@ -481,7 +481,13 @@ export function AgentGenerationWorkspaceDarkV2({
|
|||||||
imageUrl: String(item.imageUrl || "").trim(),
|
imageUrl: String(item.imageUrl || "").trim(),
|
||||||
candidateId: item.candidateId || null,
|
candidateId: item.candidateId || null,
|
||||||
sortOrder: item.sortOrder ?? 0,
|
sortOrder: item.sortOrder ?? 0,
|
||||||
assignedProductIndex: item.assignedProductIndex ?? null,
|
assignedProductIndex:
|
||||||
|
selectedProductAttachments.length > 0
|
||||||
|
? Math.min(
|
||||||
|
item.assignedProductIndex ?? 0,
|
||||||
|
Math.max(selectedProductAttachments.length - 1, 0)
|
||||||
|
)
|
||||||
|
: null,
|
||||||
})),
|
})),
|
||||||
}
|
}
|
||||||
: undefined;
|
: undefined;
|
||||||
@ -1294,26 +1300,6 @@ export function AgentGenerationWorkspaceDarkV2({
|
|||||||
),
|
),
|
||||||
}));
|
}));
|
||||||
}, [updateSkuReplacementState]);
|
}, [updateSkuReplacementState]);
|
||||||
useEffect(() => {
|
|
||||||
if (!isSkuReplacementPreset) return;
|
|
||||||
updateSkuReplacementState((current) => ({
|
|
||||||
...current,
|
|
||||||
references: current.references.map((card, index) => ({
|
|
||||||
...card,
|
|
||||||
assignedProductIndex:
|
|
||||||
selectedProductAttachments.length > 0
|
|
||||||
? Math.min(
|
|
||||||
card.assignedProductIndex ?? index,
|
|
||||||
Math.max(selectedProductAttachments.length - 1, 0)
|
|
||||||
)
|
|
||||||
: null,
|
|
||||||
})),
|
|
||||||
}));
|
|
||||||
}, [
|
|
||||||
isSkuReplacementPreset,
|
|
||||||
selectedProductAttachments.length,
|
|
||||||
updateSkuReplacementState,
|
|
||||||
]);
|
|
||||||
const handleRemoveSkuReferenceCard = useCallback((cardId: string) => {
|
const handleRemoveSkuReferenceCard = useCallback((cardId: string) => {
|
||||||
updateSkuReplacementState((current) => ({
|
updateSkuReplacementState((current) => ({
|
||||||
...current,
|
...current,
|
||||||
@ -2388,6 +2374,18 @@ export function AgentGenerationWorkspaceDarkV2({
|
|||||||
key={card.id}
|
key={card.id}
|
||||||
className="overflow-hidden rounded-[22px] border border-white/10 bg-black/20"
|
className="overflow-hidden rounded-[22px] border border-white/10 bg-black/20"
|
||||||
>
|
>
|
||||||
|
{(() => {
|
||||||
|
const resolvedAssignedProductIndex =
|
||||||
|
selectedProductAttachments.length > 0
|
||||||
|
? Math.min(
|
||||||
|
typeof card.assignedProductIndex === "number"
|
||||||
|
? card.assignedProductIndex
|
||||||
|
: index,
|
||||||
|
Math.max(selectedProductAttachments.length - 1, 0)
|
||||||
|
)
|
||||||
|
: null;
|
||||||
|
return (
|
||||||
|
<>
|
||||||
<div className="relative aspect-[5/3] overflow-hidden bg-[radial-gradient(circle_at_top,rgba(16,185,129,0.12),transparent_55%),linear-gradient(180deg,#0b0d0f_0%,#101316_100%)]">
|
<div className="relative aspect-[5/3] overflow-hidden bg-[radial-gradient(circle_at_top,rgba(16,185,129,0.12),transparent_55%),linear-gradient(180deg,#0b0d0f_0%,#101316_100%)]">
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
@ -2415,8 +2413,8 @@ export function AgentGenerationWorkspaceDarkV2({
|
|||||||
<>
|
<>
|
||||||
<div className="mb-2 text-[11px] text-white/45">
|
<div className="mb-2 text-[11px] text-white/45">
|
||||||
当前对应输入图:
|
当前对应输入图:
|
||||||
{typeof card.assignedProductIndex === "number"
|
{typeof resolvedAssignedProductIndex === "number"
|
||||||
? `输入图 ${Math.min(card.assignedProductIndex + 1, selectedProductAttachments.length)}`
|
? `输入图 ${resolvedAssignedProductIndex + 1}`
|
||||||
: "未指定"}
|
: "未指定"}
|
||||||
</div>
|
</div>
|
||||||
<div className="flex flex-wrap gap-2">
|
<div className="flex flex-wrap gap-2">
|
||||||
@ -2429,7 +2427,7 @@ export function AgentGenerationWorkspaceDarkV2({
|
|||||||
}
|
}
|
||||||
className={cn(
|
className={cn(
|
||||||
"rounded-full border px-2.5 py-1 text-[11px] transition-colors",
|
"rounded-full border px-2.5 py-1 text-[11px] transition-colors",
|
||||||
card.assignedProductIndex === productIndex
|
resolvedAssignedProductIndex === productIndex
|
||||||
? "border-emerald-400/45 bg-emerald-500/[0.12] text-emerald-200"
|
? "border-emerald-400/45 bg-emerald-500/[0.12] text-emerald-200"
|
||||||
: "border-white/10 bg-white/[0.03] text-white/58 hover:border-white/20 hover:text-white"
|
: "border-white/10 bg-white/[0.03] text-white/58 hover:border-white/20 hover:text-white"
|
||||||
)}
|
)}
|
||||||
@ -2444,6 +2442,9 @@ export function AgentGenerationWorkspaceDarkV2({
|
|||||||
删除某张后,后面的参考图会自动上移补位,不留空位。
|
删除某张后,后面的参考图会自动上移补位,不留空位。
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
})()}
|
||||||
</div>
|
</div>
|
||||||
))
|
))
|
||||||
) : (
|
) : (
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user