From b762deaf1513b28f0139f722499a8e2910cc986d Mon Sep 17 00:00:00 2001 From: "DESKTOP-JKIE562\\PC" <1013397054@qq.com> Date: Tue, 1 Dec 2026 10:15:49 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E7=BF=BB=E8=AF=91=E8=BF=9B=E7=9F=A5?= =?UTF-8?q?=E8=AF=86=E5=BA=93):=E4=BF=AE=E5=A4=8D1.=E5=AF=B9=E8=AF=9D?= =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E7=9A=84=E6=96=87=E4=BB=B6=E9=9C=80=E8=A6=81?= =?UTF-8?q?=E5=90=8C=E6=AD=A5=E5=88=B0=E5=AF=B9=E5=BA=94=E7=9F=A5=E8=AF=86?= =?UTF-8?q?=E5=BA=93=EF=BC=81=E4=BD=86=E7=8E=B0=E5=9C=A8=E7=9F=A5=E8=AF=86?= =?UTF-8?q?=E5=BA=93=E9=87=8C=E6=B2=A1=E6=9C=89=E7=9C=8B=E5=88=B0=202.?= =?UTF-8?q?=E5=A6=82=E5=9B=BE=E4=B8=89=E6=89=80=E7=A4=BA=E7=82=B9=E5=87=BB?= =?UTF-8?q?=E7=9B=B8=E5=AF=B9=E4=BA=8E=E6=96=87=E4=BB=B6=E8=AF=A6=E6=83=85?= =?UTF-8?q?=E4=B8=AD=E5=9B=BE=E7=89=87=E9=83=BD=E6=B2=A1=E6=9C=89=E4=BA=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/components/document-preview.vue | 6 +++++- frontend/src/utils/xlsxDrawings.ts | 14 +++++++++++++- internal/agent/tools/xlsx_translate.go | 8 +++++++- 3 files changed, 25 insertions(+), 3 deletions(-) diff --git a/frontend/src/components/document-preview.vue b/frontend/src/components/document-preview.vue index 422f814..bd48c9b 100644 --- a/frontend/src/components/document-preview.vue +++ b/frontend/src/components/document-preview.vue @@ -410,7 +410,11 @@ async function renderExcel(blob: Blob, fileType?: string) { await nextTick(); const container = previewContent.value as HTMLElement | null; if (container && drawings.length > 0) { - mountExcelPreviewImages(container, drawings); + // Async: the mount retries while the panel fades in and logs the count, + // so a silent no-image state is diagnosable from the console. + mountExcelPreviewImages(container, drawings).then(mounted => { + console.info(`[DocumentPreview] embedded images mounted: ${mounted}/${drawings.length}`); + }); } } diff --git a/frontend/src/utils/xlsxDrawings.ts b/frontend/src/utils/xlsxDrawings.ts index 0fa3898..1664c80 100644 --- a/frontend/src/utils/xlsxDrawings.ts +++ b/frontend/src/utils/xlsxDrawings.ts @@ -163,7 +163,17 @@ export async function extractExcelImages(buf: ArrayBuffer): Promise { + // The preview panel may still be fading in when renderExcel finishes: a + // hidden table reports zero-size rects, which would collapse every image + // to 2x2 px. Wait (bounded) until the grid has real geometry. + for (let attempt = 0; attempt < 20; attempt++) { + const probe = container.querySelector('#sheet-0') as HTMLTableElement | null; + if (!probe || probe.getBoundingClientRect().width > 0) break; + await new Promise(resolve => setTimeout(resolve, 100)); + } + + let mounted = 0; for (const img of images) { const table = container.querySelector(`#sheet-${img.sheetIndex}`) as HTMLTableElement | null; if (!table) continue; @@ -207,5 +217,7 @@ export function mountExcelPreviewImages(container: HTMLElement, images: ExcelDra el.style.objectFit = 'fill'; el.style.zIndex = '5'; parent.appendChild(el); + mounted++; } + return mounted; } diff --git a/internal/agent/tools/xlsx_translate.go b/internal/agent/tools/xlsx_translate.go index 69089b6..db5349b 100644 --- a/internal/agent/tools/xlsx_translate.go +++ b/internal/agent/tools/xlsx_translate.go @@ -214,10 +214,16 @@ func (t *XlsxTranslateTool) Execute(ctx context.Context, args json.RawMessage) ( // both into the agent's knowledge base when one is selected; ingestion // runs through the normal async pipeline, so failures never block // delivering the translated workbook. - if t.ingestKB != "" && t.knowledge != nil { + switch { + case t.ingestKB != "" && t.knowledge != nil: if warn := t.ingestToKnowledge(ctx, tenantID, source, data, outName, translated); warn != "" { report.Warnings = append(report.Warnings, warn) } + default: + // Silent skipping here is how the "knowledge library stays empty" + // confusion happens — surface the missing configuration instead. + report.Warnings = append(report.Warnings, + "本智能体未勾选知识库,原件与译文未入库(管理员在智能体编辑中为本智能体勾选知识库后启用自动入库)") } logger.Infof(ctx, "[Tool][XlsxTranslate] session=%s file=%s -> %s units=%d residual=%d llm_calls=%d",