fix: restore detail market id lookup input

This commit is contained in:
Your Name 2026-06-02 15:21:24 +08:00
parent fa4b4183cf
commit 3e2261b1c7

View File

@ -1322,6 +1322,7 @@ export function AgentGenerationWorkspaceDarkV2({
isLoading: false,
lastQuery: null,
});
const [detailProductIdQueryInput, setDetailProductIdQueryInput] = useState("");
const [detailReferenceStitchDialogOpen, setDetailReferenceStitchDialogOpen] = useState(false);
const [activeDetailReferenceCardId, setActiveDetailReferenceCardId] = useState<string | null>(null);
const [skuReplacementSearchState, setSkuReplacementSearchState] = useState<{
@ -1570,18 +1571,9 @@ export function AgentGenerationWorkspaceDarkV2({
[hasAgentUploadSlots, modelSlotEnabled, modelSlotIndex, productSlotCount]
);
const isDirectReferenceUploadEnabled = isDirectModelGenerationMode && !hasMaterialStep;
const directReferenceUploadSlots = useMemo(
() =>
Array.from({ length: DIRECT_MODEL_UPLOAD_SLOT_COUNT }, (_, index) => ({
slotIndex: index,
label: `参考图${index + 1}`,
})),
[]
);
const visibleAttachmentUploadSlots = isDirectReferenceUploadEnabled
? directReferenceUploadSlots
: agentUploadSlots;
const hasVisibleAttachmentUploadSlots = visibleAttachmentUploadSlots.length > 0;
const visibleAttachmentUploadSlots = agentUploadSlots;
const hasVisibleAttachmentUploadSlots =
hasAgentUploadSlots && visibleAttachmentUploadSlots.length > 0;
const requiredProductUploadCount = hasAgentUploadSlots ? productSlotCount : 0;
const detailReferenceTarget = presetModeConfig.detail.referenceImageSource;
const skuReferenceTarget = presetModeConfig.sku.referenceImageSource;
@ -1883,11 +1875,7 @@ export function AgentGenerationWorkspaceDarkV2({
requiredProductUploadCount - filledProductAttachmentCount,
0
);
const directReferenceAttachmentCount = attachments
.slice(0, DIRECT_MODEL_UPLOAD_SLOT_COUNT)
.filter((item) => Boolean(item?.url)).length;
const productAttachmentSummary = `${selectedProductAttachments.length}/${productSlotCount} 张产品图`;
const directReferenceAttachmentSummary = `已上传 ${directReferenceAttachmentCount}/${DIRECT_MODEL_UPLOAD_SLOT_COUNT} 张参考图`;
const modelAttachmentSummary = modelSlotEnabled
? selectedModelAttachment
? "模特图已带入"
@ -1918,6 +1906,11 @@ export function AgentGenerationWorkspaceDarkV2({
selectedProductAttachments.length,
]);
const detailReplacementQueryInput = detailReplacementState.query;
const detailReplacementQueryDisplay =
detailReplacementSearchState.lastQuery ||
(detailReplacementQueryType === "productId"
? detailProductIdQueryInput.trim()
: detailReplacementQueryInput.trim().toUpperCase());
const detailReplacementCandidates = detailReplacementState.candidates;
const detailReplacementSelectedCandidateId = detailReplacementState.selectedCandidateId;
const detailGenerationMode = normalizeAgentDetailGenerationMode(
@ -2138,8 +2131,6 @@ export function AgentGenerationWorkspaceDarkV2({
const hasBrandModelStep = Boolean(brandModelPanel) && modelSlotEnabled;
const hasBrandStoreStep = Boolean(brandStorePanel);
const hasWorkflowStyleStep = Boolean(workflowStylePanel) || hasBrandModelStep;
const shouldShowDirectUploadInStyleStep =
isDirectReferenceUploadEnabled && hasWorkflowStyleStep;
const visibleWorkflowSectionKeys = useMemo(
() => [
...(hasBrandStoreStep ? ["brand"] : []),
@ -3336,14 +3327,10 @@ export function AgentGenerationWorkspaceDarkV2({
}, [activeResultModeUrls, selectedResultUrl]);
useEffect(() => {
if (isDirectReferenceUploadEnabled) {
setIsAttachmentSlotExpanded(true);
return;
}
if (!selectedAgentPresetId || !hasAgentUploadSlots) {
setIsAttachmentSlotExpanded(false);
}
}, [hasAgentUploadSlots, isDirectReferenceUploadEnabled, selectedAgentPresetId]);
}, [hasAgentUploadSlots, selectedAgentPresetId]);
useEffect(() => {
if (requiresPresetSelection && !selectedAgentPresetId) {
@ -4855,8 +4842,10 @@ export function AgentGenerationWorkspaceDarkV2({
queryType: Extract<AgentWorkflowReferenceQueryType, "spu" | "productId">
) => {
const rawPrimarySpu = getCurrentWorkflowPrimarySpu();
const rawQuery =
queryType === "productId" ? detailProductIdQueryInput : rawPrimarySpu;
const normalized =
queryType === "productId" ? rawPrimarySpu.trim() : rawPrimarySpu.trim().toUpperCase();
queryType === "productId" ? rawQuery.trim() : rawQuery.trim().toUpperCase();
const currentWorkflowBrandName = getCurrentWorkflowBrandName();
if (!currentWorkflowBrandName && queryType !== "productId") {
toast.error("请先在第一步完成品牌选择后再检索可用模版");
@ -4865,7 +4854,7 @@ export function AgentGenerationWorkspaceDarkV2({
if (!normalized) {
toast.error(
queryType === "productId"
? "请先在第一步输入主商品市场ID后再查询详情"
? "请输入市场ID或商品ID后再查询详情"
: "请先在第一步输入主商品SPU后再检索可用模版"
);
return;
@ -4925,6 +4914,7 @@ export function AgentGenerationWorkspaceDarkV2({
}, [
detailReferenceSourceLabel,
detailReferenceTarget,
detailProductIdQueryInput,
detailReplacementProductDetailChannel,
getCurrentWorkflowPrimarySpu,
getCurrentWorkflowBrandName,
@ -5349,56 +5339,43 @@ export function AgentGenerationWorkspaceDarkV2({
<div className="space-y-3">
<div className="flex items-center gap-2 text-sm font-semibold text-white">
<ImagePlus className="h-4 w-4 text-emerald-300" />
{isDirectReferenceUploadEnabled ? "上传参考图" : "输入图槽位"}
输入图槽位
</div>
{hasVisibleAttachmentUploadSlots ? (
<>
{isDirectReferenceUploadEnabled ? (
<div className="flex flex-wrap gap-2">
<span className="rounded-full border border-emerald-400/25 bg-emerald-500/[0.10] px-3 py-1 text-xs text-emerald-100">
{directReferenceAttachmentSummary}
</span>
<span className="rounded-full border border-white/10 bg-black/20 px-3 py-1 text-xs text-white/60">
可选上传,也可纯文字生成
</span>
</div>
) : (
<div className="flex flex-wrap gap-2">
<div className="flex flex-wrap gap-2">
<span
className={cn(
"rounded-full border px-3 py-1 text-xs",
attachmentSummaryReady
? "border-emerald-400/25 bg-emerald-500/[0.10] text-emerald-100"
: "border-amber-400/25 bg-amber-500/[0.10] text-amber-100"
)}
>
{productAttachmentSummary}
</span>
{modelAttachmentSummary ? (
<span
className={cn(
"rounded-full border px-3 py-1 text-xs",
attachmentSummaryReady
selectedModelAttachment
? "border-emerald-400/25 bg-emerald-500/[0.10] text-emerald-100"
: "border-amber-400/25 bg-amber-500/[0.10] text-amber-100"
: "border-white/10 bg-black/20 text-white/60"
)}
>
{productAttachmentSummary}
{modelAttachmentSummary}
</span>
{modelAttachmentSummary ? (
<span
className={cn(
"rounded-full border px-3 py-1 text-xs",
selectedModelAttachment
? "border-emerald-400/25 bg-emerald-500/[0.10] text-emerald-100"
: "border-white/10 bg-black/20 text-white/60"
)}
>
{modelAttachmentSummary}
</span>
) : null}
<span className="rounded-full border border-white/10 bg-black/20 px-3 py-1 text-xs text-white/60">
共 {agentUploadSlots.length} 个输入槽位
</span>
</div>
)}
) : null}
<span className="rounded-full border border-white/10 bg-black/20 px-3 py-1 text-xs text-white/60">
共 {agentUploadSlots.length} 个输入槽位
</span>
</div>
<p className="text-xs leading-6 text-white/55">
{isDirectReferenceUploadEnabled
? "第一步和第二步关闭时,可在这里直接上传商品图、参考图或场景图;生成时会和补充要求一起发送给模型。"
: missingAttachmentCount > 0
? `当前还需补充 ${missingAttachmentCount} 张产品图,展开后可继续检查或替换。`
: "产品图已自动带入并准备完成;模特图槽位可按需补充,不选也可以继续生成。"}
{missingAttachmentCount > 0
? `当前还需补充 ${missingAttachmentCount} 张产品图,展开后可继续检查或替换。`
: "产品图已自动带入并准备完成;模特图槽位可按需补充,不选也可以继续生成。"}
</p>
</>
) : (
@ -5415,13 +5392,7 @@ export function AgentGenerationWorkspaceDarkV2({
variant="outline"
className="border-white/12 bg-black/25 text-white/82 hover:border-white/22 hover:bg-white/[0.06] hover:text-white"
>
{isAttachmentSlotExpanded
? isDirectReferenceUploadEnabled
? "收起上传区"
: "收起素材槽位"
: isDirectReferenceUploadEnabled
? "上传参考图"
: "检查/替换素材"}
{isAttachmentSlotExpanded ? "收起素材槽位" : "检查/替换素材"}
{isAttachmentSlotExpanded ? (
<ChevronUp className="ml-2 h-4 w-4" />
) : (
@ -5435,9 +5406,7 @@ export function AgentGenerationWorkspaceDarkV2({
{hasVisibleAttachmentUploadSlots ? (
<CollapsibleContent className="mt-4 space-y-4">
<div className="rounded-[20px] border border-emerald-400/15 bg-emerald-500/[0.06] px-4 py-3 text-xs leading-6 text-emerald-100/80">
{isDirectReferenceUploadEnabled
? "当前模式不会展示前两步素材选择,上传到这里的图片会作为参考图直接参与本次模型生图。"
: "上一步已选的白底图和品牌模特图会自动带入对应槽位,这里只保留最终检查与单张上传替换,不再重复展示已选素材列表。"}
上一步已选的白底图和品牌模特图会自动带入对应槽位,这里只保留最终检查与单张上传替换,不再重复展示已选素材列表。
</div>
<div className="grid grid-cols-2 gap-3 lg:grid-cols-4">
@ -5646,7 +5615,6 @@ export function AgentGenerationWorkspaceDarkV2({
</div>
<div className="space-y-7">
{shouldShowDirectUploadInStyleStep ? attachmentSlotPanel : null}
{workflowStylePanel}
{hasBrandModelStep ? brandModelPanel : null}
</div>
@ -5845,10 +5813,7 @@ export function AgentGenerationWorkspaceDarkV2({
</div>
) : null}
{(!shouldShowDirectUploadInStyleStep && isDirectReferenceUploadEnabled) ||
(hasAgentUploadSlots && isAttachmentSlotExpanded)
? attachmentSlotPanel
: null}
{hasAgentUploadSlots && isAttachmentSlotExpanded ? attachmentSlotPanel : null}
<div className="rounded-[28px] border border-white/12 bg-white/[0.02] p-4">
<h3 className="mb-3 flex items-center gap-2 text-sm font-semibold text-white">
@ -6120,7 +6085,7 @@ export function AgentGenerationWorkspaceDarkV2({
<div>
<div className="text-sm font-semibold text-white">参考详情搜索</div>
<div className="text-xs text-white/40">
支持按 SPU / SKU 自动识别候选整套,也可以上传参考详情图或按商品ID拉取详情图。
支持自动复用主 SPU 检索素材库模版,也可以输入市场ID按渠道拉取详情图。
</div>
</div>
<div className="rounded-full border border-white/10 bg-white/[0.03] px-3 py-1 text-xs text-white/55">
@ -6134,7 +6099,7 @@ export function AgentGenerationWorkspaceDarkV2({
<div className="flex flex-col gap-4 xl:flex-row xl:items-center xl:justify-between">
<div className="min-w-0">
<div className="text-xs text-white/42">
自动复用第一步主商品信息检索参考详情,不需要重复输入 SPU / SKU。
自动复用第一步主商品信息检索参考详情;市场ID查询需要单独输入商品ID。
</div>
<div className="mt-2 flex flex-wrap gap-2">
<span className="rounded-full border border-emerald-400/20 bg-emerald-500/[0.08] px-3 py-1 text-xs text-emerald-100">
@ -6149,6 +6114,19 @@ export function AgentGenerationWorkspaceDarkV2({
</div>
</div>
<div className="flex flex-col gap-2 sm:flex-row">
<Input
value={detailProductIdQueryInput}
onChange={(event) => setDetailProductIdQueryInput(event.target.value)}
onKeyDown={(event) => {
if (event.key === "Enter") {
event.preventDefault();
handleDetailReplacementSearch("productId");
}
}}
disabled={detailReplacementSearchState.isLoading}
placeholder="输入市场ID / 商品ID"
className="h-12 rounded-[22px] border-white/10 bg-black/20 text-sm text-white placeholder:text-white/28 focus:border-emerald-400/30 sm:w-[220px]"
/>
<Select
value={detailReplacementProductDetailChannel}
onValueChange={(value) =>
@ -6215,7 +6193,7 @@ export function AgentGenerationWorkspaceDarkV2({
</div>
) : null}
{(detailReplacementSearchState.lastQuery || detailReplacementQueryInput.trim()) ? (
{detailReplacementQueryDisplay ? (
<div className="rounded-[18px] border border-white/10 bg-white/[0.03] px-3 py-2 text-xs text-white/48">
当前参考图查询:
{detailReplacementQueryType === "productId"
@ -6223,10 +6201,7 @@ export function AgentGenerationWorkspaceDarkV2({
: detailReplacementQueryType === "sku"
? "SKU"
: "SPU"} /
{detailReplacementSearchState.lastQuery ||
(detailReplacementQueryType === "productId"
? detailReplacementQueryInput.trim()
: detailReplacementQueryInput.trim().toUpperCase())}
{detailReplacementQueryDisplay}
{workflowBrandName ? (
<span className="ml-2 text-white/40">{`品牌 / ${workflowBrandName}`}</span>
) : null}