fix(翻译进知识库):修复1.对话上传的文件需要同步到对应知识库!但现在知识库里没有看到
deploy-hxtesting / build-and-deploy (push) Successful in 1m20s

2.如图三所示点击相对于文件详情中图片都没有了
This commit is contained in:
runny committed 2026-12-01 10:15:49 +08:00
1 parent a6632e7b55
commit b762deaf15
3 files changed
+25 -3

No files matched your search

+5 -1
View File
@@ -410,7 +410,11 @@ async function renderExcel(blob: Blob, fileType?: string) {
await nextTick(); await nextTick();
const container = previewContent.value as HTMLElement | null; const container = previewContent.value as HTMLElement | null;
if (container && drawings.length > 0) { 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}`);
});
} }
} }
+13 -1
View File
@@ -163,7 +163,17 @@ export async function extractExcelImages(buf: ArrayBuffer): Promise<ExcelDrawing
* images follow the actual row/column sizes. Anchors beyond the rendered * images follow the actual row/column sizes. Anchors beyond the rendered
* extent clamp to the table edge. * extent clamp to the table edge.
*/ */
export function mountExcelPreviewImages(container: HTMLElement, images: ExcelDrawingImage[]): void { export async function mountExcelPreviewImages(container: HTMLElement, images: ExcelDrawingImage[]): Promise<number> {
// 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) { for (const img of images) {
const table = container.querySelector(`#sheet-${img.sheetIndex}`) as HTMLTableElement | null; const table = container.querySelector(`#sheet-${img.sheetIndex}`) as HTMLTableElement | null;
if (!table) continue; if (!table) continue;
@@ -207,5 +217,7 @@ export function mountExcelPreviewImages(container: HTMLElement, images: ExcelDra
el.style.objectFit = 'fill'; el.style.objectFit = 'fill';
el.style.zIndex = '5'; el.style.zIndex = '5';
parent.appendChild(el); parent.appendChild(el);
mounted++;
} }
return mounted;
} }
+7 -1
View File
@@ -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 // both into the agent's knowledge base when one is selected; ingestion
// runs through the normal async pipeline, so failures never block // runs through the normal async pipeline, so failures never block
// delivering the translated workbook. // 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 != "" { if warn := t.ingestToKnowledge(ctx, tenantID, source, data, outName, translated); warn != "" {
report.Warnings = append(report.Warnings, 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", logger.Infof(ctx, "[Tool][XlsxTranslate] session=%s file=%s -> %s units=%d residual=%d llm_calls=%d",