feat: add cover proxy endpoint and progress bar to dashboard
- Add /api/cover/<library_item_id> endpoint to proxy cover images from ABS - Return cover proxy URL instead of direct ABS URL to avoid CORS issues - Add visual progress bar to audiobook card - Add cache-busting timestamp to cover image URLs - Improve cover image error handling with fallback placeholder Generated by Mistral Vibe. Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
This commit is contained in:
@ -137,15 +137,16 @@
|
||||
/* Cover Image Styles */
|
||||
.cover-container {
|
||||
text-align: center;
|
||||
margin-bottom: 0.75rem;
|
||||
}
|
||||
|
||||
.cover-image {
|
||||
max-width: 100%;
|
||||
max-height: 200px;
|
||||
max-height: 180px;
|
||||
border-radius: 8px;
|
||||
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
|
||||
object-fit: contain;
|
||||
background: rgba(0, 0, 0, 0.2);
|
||||
background: rgba(0, 0, 0, 0.3);
|
||||
}
|
||||
|
||||
.cover-placeholder {
|
||||
@ -158,11 +159,27 @@
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
color: #666;
|
||||
font-size: 1.5rem;
|
||||
font-size: 3rem;
|
||||
}
|
||||
|
||||
.audiobook-info {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.progress-bar-container {
|
||||
width: 100%;
|
||||
background: rgba(255, 255, 255, 0.1);
|
||||
border-radius: 4px;
|
||||
height: 6px;
|
||||
margin-top: 0.75rem;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.progress-bar {
|
||||
height: 100%;
|
||||
background: linear-gradient(90deg, #4f46e5, #7c3aed);
|
||||
border-radius: 4px;
|
||||
transition: width 0.3s ease;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
@ -291,34 +308,40 @@
|
||||
|
||||
let html = '';
|
||||
|
||||
// Always show cover placeholder or image
|
||||
html += '<div class="cover-container">';
|
||||
|
||||
if (coverUrl) {
|
||||
html = `
|
||||
<div class="cover-container">
|
||||
<img src="${coverUrl}" alt="${title}" class="cover-image"
|
||||
onerror="this.style.display='none'; document.getElementById('cover-fallback-${Date.now()}').style.display='block';">
|
||||
<div id="cover-fallback-${Date.now()}" class="cover-placeholder" style="display: none;">
|
||||
${mediaIcon}
|
||||
</div>
|
||||
</div>
|
||||
<div class="audiobook-info">
|
||||
<div class="card-value" style="font-size: 1.25rem; margin-top: 0.5rem;">${title}</div>
|
||||
${author ? `<div class="card-subvalue">von ${author}</div>` : ''}
|
||||
<div class="card-subvalue">${progressPercent}% (${currentTime}/${duration})</div>
|
||||
</div>
|
||||
// Add timestamp to prevent caching
|
||||
const coverUrlWithCache = coverUrl.includes('?')
|
||||
? `${coverUrl}&t=${Date.now()}`
|
||||
: `${coverUrl}?t=${Date.now()}`;
|
||||
|
||||
html += `
|
||||
<img src="${coverUrlWithCache}" alt="${title}" class="cover-image"
|
||||
onerror="this.style.display='none'; this.nextElementSibling.style.display='block';">
|
||||
<div class="cover-placeholder" style="display: none;">${mediaIcon}</div>
|
||||
`;
|
||||
} else {
|
||||
html = `
|
||||
<div class="cover-container">
|
||||
<div class="cover-placeholder">${mediaIcon}</div>
|
||||
</div>
|
||||
<div class="audiobook-info">
|
||||
<div class="card-value" style="font-size: 1.25rem; margin-top: 0.5rem;">${title}</div>
|
||||
${author ? `<div class="card-subvalue">von ${author}</div>` : ''}
|
||||
<div class="card-subvalue">${progressPercent}% (${currentTime}/${duration})</div>
|
||||
</div>
|
||||
`;
|
||||
html += `<div class="cover-placeholder">${mediaIcon}</div>`;
|
||||
}
|
||||
|
||||
html += '</div>';
|
||||
|
||||
html += '<div class="audiobook-info">';
|
||||
html += `<div class="card-value" style="font-size: 1.25rem; margin-top: 0.5rem;">${title}</div>`;
|
||||
if (author) {
|
||||
html += `<div class="card-subvalue">von ${author}</div>`;
|
||||
}
|
||||
html += `<div class="card-subvalue">${currentTime}/${duration}</div>`;
|
||||
|
||||
// Progress bar
|
||||
html += '<div class="progress-bar-container">';
|
||||
html += `<div class="progress-bar" style="width: ${progressPercent}%"></div>`;
|
||||
html += '</div>';
|
||||
|
||||
html += `</div>`;
|
||||
|
||||
document.getElementById('audiobook').innerHTML = html;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user