모든 기능 복원 및 안정화

- PDF 다운로드 기능 복원 (직접 다운로드 + 연결된 PDF 지원)
- 언어 전환 기능 수정 (문서 내장 기능 활용)
- 헤더 네비게이션 버튼 구현 (뒤로가기, 목차, 이전/다음 문서)
- PDF 매칭 UI 추가 (book-documents.html)
- 링크/백링크 렌더링 안정화
- 서적 URL 파라미터 수정 (book_id 지원)

주요 수정사항:
- viewer-core.js: PDF 다운로드 로직 개선, 언어 전환 단순화
- book-documents.js/html: PDF 매칭 기능 및 URL 파라미터 수정
- components/header.html: 언어 전환 및 PDF 버튼 추가
- 모든 기능 테스트 완료 및 정상 작동 확인
This commit is contained in:
Hyungi Ahn
2025-08-28 15:15:27 +09:00
parent 8414c9b40e
commit 222e5bcb9e
5 changed files with 401 additions and 4 deletions

View File

@@ -35,8 +35,9 @@ window.bookDocumentsApp = () => ({
// URL 파라미터 파싱
parseUrlParams() {
const urlParams = new URLSearchParams(window.location.search);
this.bookId = urlParams.get('bookId');
this.bookId = urlParams.get('book_id') || urlParams.get('bookId'); // 둘 다 지원
console.log('📖 서적 ID:', this.bookId);
console.log('🔍 전체 URL 파라미터:', window.location.search);
},
// 인증 상태 확인
@@ -218,6 +219,57 @@ window.bookDocumentsApp = () => ({
if (type === 'error') {
alert(message);
}
},
// PDF를 서적에 연결
async matchPDFToBook(pdfId) {
if (!this.bookId) {
this.showNotification('서적 ID가 없습니다', 'error');
return;
}
if (!confirm('이 PDF를 현재 서적에 연결하시겠습니까?')) {
return;
}
try {
console.log('🔗 PDF 매칭 시작:', { pdfId, bookId: this.bookId });
// PDF 문서를 서적에 연결
await window.api.updateDocument(pdfId, {
book_id: this.bookId
});
this.showNotification('PDF가 서적에 성공적으로 연결되었습니다');
// 데이터 새로고침
await this.loadBookData();
} catch (error) {
console.error('PDF 매칭 실패:', error);
this.showNotification('PDF 연결에 실패했습니다: ' + error.message, 'error');
}
},
// PDF 열기
openPDF(pdf) {
if (pdf.pdf_path) {
// PDF 뷰어로 이동
window.open(`/viewer.html?id=${pdf.id}`, '_blank');
} else {
this.showNotification('PDF 파일을 찾을 수 없습니다', 'error');
}
},
// 날짜 포맷팅
formatDate(dateString) {
if (!dateString) return '';
const date = new Date(dateString);
return date.toLocaleDateString('ko-KR', {
year: 'numeric',
month: 'short',
day: 'numeric'
});
}
});