From dc1665d7bad1bb54b7c1f00e43ad84c1ebbaaca2 Mon Sep 17 00:00:00 2001 From: Your Name Date: Sun, 22 Mar 2026 23:54:49 +0800 Subject: [PATCH] fix: restore sku goods info display --- .../agent-workflow/material-search/route.ts | 44 ++++++++++++++++--- .../agents/AgentWorkflowPanelDarkV2.tsx | 22 ---------- 2 files changed, 37 insertions(+), 29 deletions(-) diff --git a/app/api/agent-workflow/material-search/route.ts b/app/api/agent-workflow/material-search/route.ts index 730634e22..238737a10 100644 --- a/app/api/agent-workflow/material-search/route.ts +++ b/app/api/agent-workflow/material-search/route.ts @@ -1,4 +1,5 @@ import { generateText } from "ai"; +import { execFileSync } from "node:child_process"; import { createCipheriv, createHash } from "node:crypto"; import { NextRequest, NextResponse } from "next/server"; import { z } from "zod"; @@ -87,13 +88,42 @@ function createGoodsInfoSignature(timespan: string, secret: string) { throw new Error("商品信息接口 Secret 长度必须为 8 位"); } - const cipher = createCipheriv("des-cbc", secretBuffer, secretBuffer); - cipher.setAutoPadding(true); - const encrypted = Buffer.concat([ - cipher.update(String(timespan || "").trim(), "utf8"), - cipher.final(), - ]); - const encryptedHex = encrypted.toString("hex").toUpperCase(); + const plaintext = String(timespan || "").trim(); + let encryptedHex = ""; + + try { + const cipher = createCipheriv("des-cbc", secretBuffer, secretBuffer); + cipher.setAutoPadding(true); + const encrypted = Buffer.concat([ + cipher.update(plaintext, "utf8"), + cipher.final(), + ]); + encryptedHex = encrypted.toString("hex").toUpperCase(); + } catch (error) { + const opensslOutput = execFileSync( + "openssl", + [ + "enc", + "-des-cbc", + "-provider", + "legacy", + "-K", + secretBuffer.toString("hex"), + "-iv", + secretBuffer.toString("hex"), + "-nosalt", + ], + { + input: Buffer.from(plaintext, "utf8"), + } + ); + encryptedHex = Buffer.from(opensslOutput).toString("hex").toUpperCase(); + console.warn( + "[Agent Workflow Material Search] Fallback to openssl legacy DES for goods info signature:", + error instanceof Error ? error.message : error + ); + } + return createHash("md5").update(encryptedHex, "utf8").digest("hex").toUpperCase(); } diff --git a/components/agents/AgentWorkflowPanelDarkV2.tsx b/components/agents/AgentWorkflowPanelDarkV2.tsx index 720762afb..bf2274aa5 100644 --- a/components/agents/AgentWorkflowPanelDarkV2.tsx +++ b/components/agents/AgentWorkflowPanelDarkV2.tsx @@ -641,28 +641,6 @@ export function AgentWorkflowPanelDarkV2({ )) )} - {/* 当前选择摘要 */} - {summary.length > 0 && ( - -

当前选择

-
- {summary.map((item) => ( -
- {item.stepTitle} - {item.optionName} -
- ))} -
-
- )} - {/* Prompt 预览 */}