fix: align agent preset detail search and timezone
This commit is contained in:
parent
043bbab84d
commit
9a96824e2b
@ -555,7 +555,6 @@ export function AgentGenerationWorkspaceDarkV2({
|
||||
const emitAgentModeState = onAgentModeStateChange || setLocalAgentModeState;
|
||||
const detailReplacementState = resolvedAgentModeState.detailReplacement;
|
||||
const detailReplacementQueryInput = detailReplacementState.query;
|
||||
const detailReplacementQueryType = detailReplacementState.queryType;
|
||||
const detailReplacementCandidates = detailReplacementState.candidates;
|
||||
const detailReplacementSelectedCandidateId = detailReplacementState.selectedCandidateId;
|
||||
const detailReplacementReferenceCards = detailReplacementState.references;
|
||||
@ -608,7 +607,7 @@ export function AgentGenerationWorkspaceDarkV2({
|
||||
? detailReplacementQueryInput.trim()
|
||||
: skuReplacementQueryInput.trim(),
|
||||
queryType: isDetailReplacementPreset
|
||||
? detailReplacementQueryType
|
||||
? ("spu" as const)
|
||||
: skuReplacementQueryType,
|
||||
selectedCandidateId: isDetailReplacementPreset
|
||||
? detailReplacementSelectedCandidateId || null
|
||||
@ -1491,7 +1490,7 @@ export function AgentGenerationWorkspaceDarkV2({
|
||||
const handleDetailReplacementSearch = useCallback(async () => {
|
||||
const normalized = detailReplacementQueryInput.trim().toUpperCase();
|
||||
if (!normalized) {
|
||||
toast.error(`请输入${detailReplacementQueryType === "spu" ? "SPU" : "SKU"}后再查询详情图`);
|
||||
toast.error("请输入 SPU 后再查询详情图");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1504,7 +1503,7 @@ export function AgentGenerationWorkspaceDarkV2({
|
||||
const response = await fetch(
|
||||
`/api/agent-workflow/reference-search?keyword=${encodeURIComponent(
|
||||
normalized
|
||||
)}&queryType=${detailReplacementQueryType}&target=detail`,
|
||||
)}&queryType=spu&target=detail`,
|
||||
{ cache: "no-store" }
|
||||
);
|
||||
const result = (await response.json().catch(() => ({}))) as AgentModeReferenceSearchResponse;
|
||||
@ -1515,7 +1514,7 @@ export function AgentGenerationWorkspaceDarkV2({
|
||||
|
||||
updateDetailReplacementState({
|
||||
query: normalized,
|
||||
queryType: result.data.queryType || detailReplacementQueryType,
|
||||
queryType: "spu",
|
||||
candidates: result.data.candidates || [],
|
||||
selectedCandidateId:
|
||||
result.data.selectedCandidateId || result.data.candidates?.[0]?.id || null,
|
||||
@ -1533,7 +1532,7 @@ export function AgentGenerationWorkspaceDarkV2({
|
||||
});
|
||||
toast.error(error instanceof Error ? error.message : "详情参考图查询失败");
|
||||
}
|
||||
}, [detailReplacementQueryInput, detailReplacementQueryType, updateDetailReplacementState]);
|
||||
}, [detailReplacementQueryInput, updateDetailReplacementState]);
|
||||
const handleSelectDetailReplacementCandidate = useCallback((candidateId: string) => {
|
||||
updateDetailReplacementState((current) => {
|
||||
const nextCandidate =
|
||||
@ -2296,7 +2295,7 @@ export function AgentGenerationWorkspaceDarkV2({
|
||||
<div>
|
||||
<div className="text-sm font-semibold text-white">详情参考图</div>
|
||||
<div className="text-xs text-white/40">
|
||||
支持按 SPU 或 SKU 查询任务-详情整套候选,并切换某一套的详情参考图。
|
||||
仅支持按 SPU 查询任务-详情整套候选,并切换某一套的详情参考图。
|
||||
</div>
|
||||
</div>
|
||||
<div className="rounded-full border border-white/10 bg-white/[0.03] px-3 py-1 text-xs text-white/55">
|
||||
@ -2304,33 +2303,10 @@ export function AgentGenerationWorkspaceDarkV2({
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="mb-3 flex flex-wrap gap-2">
|
||||
{(["spu", "sku"] as const).map((queryType) => (
|
||||
<button
|
||||
key={queryType}
|
||||
type="button"
|
||||
onClick={() =>
|
||||
updateDetailReplacementState((current) => ({
|
||||
...current,
|
||||
queryType,
|
||||
candidates:
|
||||
current.queryType === queryType ? current.candidates : [],
|
||||
selectedCandidateId:
|
||||
current.queryType === queryType ? current.selectedCandidateId : null,
|
||||
references:
|
||||
current.queryType === queryType ? current.references : [],
|
||||
}))
|
||||
}
|
||||
className={cn(
|
||||
"rounded-full border px-3 py-1.5 text-xs transition-colors",
|
||||
detailReplacementQueryType === queryType
|
||||
? "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/18 hover:text-white"
|
||||
)}
|
||||
>
|
||||
按{queryType === "spu" ? "SPU" : "SKU"}查询
|
||||
</button>
|
||||
))}
|
||||
<div className="mb-3">
|
||||
<div className="inline-flex rounded-full border border-emerald-400/35 bg-emerald-500/[0.10] px-3 py-1.5 text-xs text-emerald-200">
|
||||
按SPU查询
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="mb-3 flex flex-col gap-2 sm:flex-row">
|
||||
@ -2339,9 +2315,10 @@ export function AgentGenerationWorkspaceDarkV2({
|
||||
onChange={(e) =>
|
||||
updateDetailReplacementState({
|
||||
query: e.target.value,
|
||||
queryType: "spu",
|
||||
})
|
||||
}
|
||||
placeholder={`输入${detailReplacementQueryType === "spu" ? "SPU" : "SKU"},查询任务-详情整套中的详情参考图`}
|
||||
placeholder="输入 SPU,查询任务-详情整套中的详情参考图"
|
||||
className="min-h-[68px] resize-none rounded-[22px] border-white/10 bg-black/20 text-sm text-white placeholder:text-white/22 focus:border-emerald-400/30"
|
||||
/>
|
||||
<Button
|
||||
@ -2374,7 +2351,7 @@ export function AgentGenerationWorkspaceDarkV2({
|
||||
{(detailReplacementSearchState.lastQuery || detailReplacementQueryInput.trim()) ? (
|
||||
<div className="mb-3 rounded-[18px] border border-white/10 bg-white/[0.03] px-3 py-2 text-xs text-white/48">
|
||||
当前参考图查询:
|
||||
{detailReplacementQueryType === "spu" ? "SPU" : "SKU"} /
|
||||
SPU /
|
||||
{detailReplacementSearchState.lastQuery ||
|
||||
detailReplacementQueryInput.trim().toUpperCase()}
|
||||
<span className="ml-2 text-emerald-200/70">
|
||||
@ -2510,7 +2487,7 @@ export function AgentGenerationWorkspaceDarkV2({
|
||||
<div className="flex min-h-[220px] flex-col items-center justify-center rounded-[22px] border border-dashed border-white/12 bg-black/20 px-5 text-center">
|
||||
<div className="text-sm font-medium text-white/72">等待详情参考图</div>
|
||||
<div className="mt-2 text-xs leading-6 text-white/40">
|
||||
输入 SPU 或 SKU 后,这里会展示任务-详情整套里的真实详情参考图。
|
||||
输入 SPU 后,这里会展示任务-详情整套里的真实详情参考图。
|
||||
删除不需要的参考图后,列表会自动上移补位。
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -35,6 +35,7 @@ export function AgentPresetCard({
|
||||
const raw = preset.createdAt ? new Date(preset.createdAt) : null;
|
||||
if (!raw || Number.isNaN(raw.getTime())) return "未知时间";
|
||||
return raw.toLocaleDateString("zh-CN", {
|
||||
timeZone: "Asia/Shanghai",
|
||||
year: "numeric",
|
||||
month: "2-digit",
|
||||
day: "2-digit",
|
||||
|
||||
@ -42,6 +42,7 @@ export function AgentPresetCardDark({
|
||||
const raw = preset.createdAt ? new Date(preset.createdAt) : null;
|
||||
if (!raw || Number.isNaN(raw.getTime())) return "";
|
||||
return raw.toLocaleDateString("zh-CN", {
|
||||
timeZone: "Asia/Shanghai",
|
||||
month: "short",
|
||||
day: "numeric",
|
||||
});
|
||||
|
||||
@ -40,6 +40,7 @@ export function AgentPresetCardNew({
|
||||
const raw = preset.createdAt ? new Date(preset.createdAt) : null;
|
||||
if (!raw || Number.isNaN(raw.getTime())) return "未知时间";
|
||||
return raw.toLocaleDateString("zh-CN", {
|
||||
timeZone: "Asia/Shanghai",
|
||||
year: "numeric",
|
||||
month: "2-digit",
|
||||
day: "2-digit",
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user