From ca49ffec407ff4a33bcae11e4f6a5a76eba6f8d3 Mon Sep 17 00:00:00 2001 From: Hyungi Ahn Date: Wed, 3 Sep 2025 18:31:35 +0900 Subject: [PATCH] =?UTF-8?q?Fix:=20PDF=20=EB=8B=A4=EC=9A=B4=EB=A1=9C?= =?UTF-8?q?=EB=93=9C=20=EC=8B=9C=20=EC=BA=90=EC=8B=9C=20=EB=AC=B8=EC=A0=9C?= =?UTF-8?q?=20=ED=95=B4=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 문서 뷰어에서 PDF 다운로드 시 최신 문서 정보를 재로드 - 캐시된 matched_pdf_id가 null인 경우 데이터베이스에서 최신 정보 가져오기 - PDF 매칭 정보 업데이트 로그 추가 --- frontend/static/js/book-editor.js | 7 +++++++ frontend/static/js/viewer/viewer-core.js | 22 ++++++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/frontend/static/js/book-editor.js b/frontend/static/js/book-editor.js index 8344806..45afce4 100644 --- a/frontend/static/js/book-editor.js +++ b/frontend/static/js/book-editor.js @@ -90,6 +90,13 @@ window.bookEditorApp = () => ({ console.log('📄 서적 문서들:', this.documents.length, '개'); + // 각 문서의 PDF 매칭 상태 확인 + this.documents.forEach((doc, index) => { + console.log(`📄 문서 ${index + 1}: ${doc.title}`); + console.log(` - matched_pdf_id: ${doc.matched_pdf_id || 'null'}`); + console.log(` - sort_order: ${doc.sort_order || 'null'}`); + }); + // 사용 가능한 PDF 문서들 로드 (현재 서적의 PDF만) console.log('🔍 현재 서적 ID:', this.bookId); console.log('🔍 전체 문서 수:', allDocuments.length); diff --git a/frontend/static/js/viewer/viewer-core.js b/frontend/static/js/viewer/viewer-core.js index 7fa700b..75088b3 100644 --- a/frontend/static/js/viewer/viewer-core.js +++ b/frontend/static/js/viewer/viewer-core.js @@ -1020,6 +1020,28 @@ window.documentViewer = () => ({ pdf_path: this.document.pdf_path }); + // 캐시를 무시하고 최신 문서 정보를 다시 가져오기 + console.log('🔄 최신 문서 정보 재로드 중...'); + try { + const freshDocument = await this.api.getDocument(this.document.id); + console.log('📄 최신 문서 정보:', { + id: freshDocument.id, + matched_pdf_id: freshDocument.matched_pdf_id, + pdf_path: freshDocument.pdf_path + }); + + // 최신 정보로 업데이트 + if (freshDocument.matched_pdf_id !== this.document.matched_pdf_id) { + console.log('🔄 PDF 매칭 정보 업데이트:', { + old: this.document.matched_pdf_id, + new: freshDocument.matched_pdf_id + }); + this.document.matched_pdf_id = freshDocument.matched_pdf_id; + } + } catch (error) { + console.error('❌ 최신 문서 정보 로드 실패:', error); + } + // 1. 현재 문서 자체가 PDF인 경우 if (this.document.pdf_path) { console.log('📄 현재 문서가 PDF - 직접 다운로드');