mirror of
https://github.com/KingHWJ/WeReadBoard.git
synced 2026-11-03 18:24:58 +08:00
fix(discovery): 修复真实书籍封面显示
This commit is contained in:
1 parent
db8d5fc391
commit
d33601c987
2 files changed
+12
-3
No files matched your search
@@ -9,3 +9,6 @@
|
|||||||
@media(max-width:600px){.compact-value{font-size:20px}.list-art .mini-cover{width:56px}.full-books .cover{width:105px;height:159px}.goal-card .section-head{gap:10px}.book-row .mini-cover{display:none}.detail-tabs{gap:16px}.date-fields input{min-height:40px}.detail-info .primary{font-size:11px;padding:9px}}
|
@media(max-width:600px){.compact-value{font-size:20px}.list-art .mini-cover{width:56px}.full-books .cover{width:105px;height:159px}.goal-card .section-head{gap:10px}.book-row .mini-cover{display:none}.detail-tabs{gap:16px}.date-fields input{min-height:40px}.detail-info .primary{font-size:11px;padding:9px}}
|
||||||
.mini-cover.c2,.mini-cover.c3{color:#fff5df}
|
.mini-cover.c2,.mini-cover.c3{color:#fff5df}
|
||||||
.export-preview{width:100%;height:320px;margin-top:20px;border:1px solid var(--line);border-radius:8px;padding:18px;background:var(--bg);color:var(--text);font:12px/1.9 'PingFang SC',sans-serif;resize:vertical}
|
.export-preview{width:100%;height:320px;margin-top:20px;border:1px solid var(--line);border-radius:8px;padding:18px;background:var(--bg);color:var(--text);font:12px/1.9 'PingFang SC',sans-serif;resize:vertical}
|
||||||
|
.real-cover{display:block;width:118px;height:168px;object-fit:cover;border-radius:4px;box-shadow:4px 5px 10px #0002;background:var(--quote)}
|
||||||
|
.mini-real-cover{width:66px;height:92px;flex-shrink:0}
|
||||||
|
.book-row .mini-real-cover{width:42px;height:58px}
|
||||||
+9
-3
@@ -78,11 +78,17 @@ $('#theme').onclick = () => {
|
|||||||
try { localStorage.setItem('weread-theme', theme); } catch { toast('主题已切换,本次浏览有效。'); }
|
try { localStorage.setItem('weread-theme', theme); } catch { toast('主题已切换,本次浏览有效。'); }
|
||||||
};
|
};
|
||||||
|
|
||||||
/* 封面:沿用设计稿的示意封面(4 种底色 + 书名短行) */
|
/* 封面:优先显示微信读书返回的真实封面,加载失败时回退到示意封面 */
|
||||||
function cover(book, mini = false) {
|
function cover(book, mini = false) {
|
||||||
const short = book.short || book.title || '';
|
const short = book.short || book.title || '';
|
||||||
if (mini) return `<div class="mini-cover ${book.cover}" aria-hidden="true"><b>${esc(book.title)}</b><small>${esc(book.author)}</small></div>`;
|
const coverUrl = book.cover_url || (typeof book.cover === 'string' && /^https?:\/\//i.test(book.cover) ? book.cover : '');
|
||||||
return `<div class="cover ${book.cover}"><span class="tiny">${esc(book.en || '')}</span><span class="title">${esc(short).replaceAll('\n', '<br>')}</span><span class="author">${esc(book.author)}</span><span class="publisher">READING SPACE · 藏书</span></div>`;
|
const coverClass = typeof book.cover === 'string' && !/^https?:\/\//i.test(book.cover) ? book.cover : '';
|
||||||
|
const fallback = mini
|
||||||
|
? `<div class="mini-cover ${coverClass}" aria-hidden="true"><b>${esc(book.title)}</b><small>${esc(book.author)}</small></div>`
|
||||||
|
: `<div class="cover ${coverClass}"><span class="tiny">${esc(book.en || '')}</span><span class="title">${esc(short).replaceAll('\n', '<br>')}</span><span class="author">${esc(book.author)}</span><span class="publisher">READING SPACE · 藏书</span></div>`;
|
||||||
|
if (!coverUrl) return fallback;
|
||||||
|
const className = mini ? 'real-cover mini-real-cover' : 'real-cover';
|
||||||
|
return `<img class="${className}" src="${esc(coverUrl)}" alt="${esc(book.title)}" loading="lazy" onerror='this.outerHTML=${JSON.stringify(fallback)}'>`;
|
||||||
}
|
}
|
||||||
function scoreText(book) {
|
function scoreText(book) {
|
||||||
return book.score ? `评分 ${Math.round(Number(book.score) * 10)}/100` : '暂无评分';
|
return book.score ? `评分 ${Math.round(Number(book.score) * 10)}/100` : '暂无评分';
|
||||||
|
|||||||
Reference in new issue
Block a user