Fix document links and backlinks rendering issue
- Fixed CachedAPI endpoint routing: /documents/{id}/links was incorrectly routed to getDocument()
- Added proper pattern matching for document API calls using regex
- Fixed link and backlink API calls to use correct getDocumentLinks() and getDocumentBacklinks() methods
- Added comprehensive debugging logs for API response tracking
- Resolved issue where links were not rendering in document viewer
Changes:
- cached-api.js: Fixed endpoint routing with proper regex pattern matching
- link-manager.js: Enhanced debugging and API response handling
- viewer-core.js: Added closeAllModals() to prevent modal auto-opening
Result: Document links and backlinks now render correctly (8 links restored)
This commit is contained in:
@@ -27,13 +27,37 @@ class LinkManager {
|
||||
async loadDocumentLinks(documentId) {
|
||||
try {
|
||||
console.log('📡 링크 API 호출:', `/documents/${documentId}/links`);
|
||||
const response = await this.cachedApi.get(`/documents/${documentId}/links`, {}, { category: 'links' }).catch(() => []);
|
||||
this.documentLinks = Array.isArray(response) ? response : [];
|
||||
console.log('📡 API 응답 링크 개수:', this.documentLinks.length);
|
||||
console.log('📡 API 응답 타입:', typeof response, response);
|
||||
console.log('📡 사용 중인 documentId:', documentId);
|
||||
console.log('📡 cachedApi 객체:', this.cachedApi);
|
||||
const response = await this.cachedApi.get(`/documents/${documentId}/links`, {}, { category: 'links' });
|
||||
console.log('📡 원본 API 응답:', response);
|
||||
console.log('📡 응답 타입:', typeof response);
|
||||
console.log('📡 응답이 배열인가?', Array.isArray(response));
|
||||
console.log('📡 응답 JSON 문자열:', JSON.stringify(response, null, 2));
|
||||
console.log('📡 응답 키들:', Object.keys(response || {}));
|
||||
|
||||
// API 응답이 객체일 경우 처리
|
||||
if (Array.isArray(response)) {
|
||||
this.documentLinks = response;
|
||||
} else if (response && typeof response === 'object') {
|
||||
// 객체에서 배열 추출 시도
|
||||
if (response.data && Array.isArray(response.data)) {
|
||||
this.documentLinks = response.data;
|
||||
} else if (response.links && Array.isArray(response.links)) {
|
||||
this.documentLinks = response.links;
|
||||
} else {
|
||||
console.warn('⚠️ 예상치 못한 API 응답 구조:', response);
|
||||
this.documentLinks = [];
|
||||
}
|
||||
} else {
|
||||
this.documentLinks = [];
|
||||
}
|
||||
|
||||
console.log('📡 최종 링크 데이터:', this.documentLinks);
|
||||
console.log('📡 최종 링크 개수:', this.documentLinks.length);
|
||||
return this.documentLinks;
|
||||
} catch (error) {
|
||||
console.error('문서 링크 로드 실패:', error);
|
||||
console.error('❌ 문서 링크 로드 실패:', error);
|
||||
this.documentLinks = [];
|
||||
return [];
|
||||
}
|
||||
@@ -45,13 +69,35 @@ class LinkManager {
|
||||
async loadBacklinks(documentId) {
|
||||
try {
|
||||
console.log('📡 백링크 API 호출:', `/documents/${documentId}/backlinks`);
|
||||
const response = await this.cachedApi.get(`/documents/${documentId}/backlinks`, {}, { category: 'links' }).catch(() => []);
|
||||
this.backlinks = Array.isArray(response) ? response : [];
|
||||
console.log('📡 API 응답 백링크 개수:', this.backlinks.length);
|
||||
console.log('📡 API 응답 타입:', typeof response, response);
|
||||
const response = await this.cachedApi.get(`/documents/${documentId}/backlinks`, {}, { category: 'links' });
|
||||
console.log('📡 원본 백링크 응답:', response);
|
||||
console.log('📡 백링크 응답 타입:', typeof response);
|
||||
console.log('📡 백링크 응답이 배열인가?', Array.isArray(response));
|
||||
console.log('📡 백링크 응답 JSON 문자열:', JSON.stringify(response, null, 2));
|
||||
console.log('📡 백링크 응답 키들:', Object.keys(response || {}));
|
||||
|
||||
// API 응답이 객체일 경우 처리
|
||||
if (Array.isArray(response)) {
|
||||
this.backlinks = response;
|
||||
} else if (response && typeof response === 'object') {
|
||||
// 객체에서 배열 추출 시도
|
||||
if (response.data && Array.isArray(response.data)) {
|
||||
this.backlinks = response.data;
|
||||
} else if (response.backlinks && Array.isArray(response.backlinks)) {
|
||||
this.backlinks = response.backlinks;
|
||||
} else {
|
||||
console.warn('⚠️ 예상치 못한 백링크 API 응답 구조:', response);
|
||||
this.backlinks = [];
|
||||
}
|
||||
} else {
|
||||
this.backlinks = [];
|
||||
}
|
||||
|
||||
console.log('📡 최종 백링크 데이터:', this.backlinks);
|
||||
console.log('📡 최종 백링크 개수:', this.backlinks.length);
|
||||
return this.backlinks;
|
||||
} catch (error) {
|
||||
console.error('백링크 로드 실패:', error);
|
||||
console.error('❌ 백링크 로드 실패:', error);
|
||||
this.backlinks = [];
|
||||
return [];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user