From d33601c9872d62c8559dc781980a4b22f6f5f5ac Mon Sep 17 00:00:00 2001 From: kinghwj Date: Fri, 11 Sep 2026 21:48:04 +0800 Subject: [PATCH] =?UTF-8?q?fix(discovery):=20=E4=BF=AE=E5=A4=8D=E7=9C=9F?= =?UTF-8?q?=E5=AE=9E=E4=B9=A6=E7=B1=8D=E5=B0=81=E9=9D=A2=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- static/css/styles.css | 3 +++ static/js/app.js | 12 +++++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/static/css/styles.css b/static/css/styles.css index c40ae2d..ba07797 100644 --- a/static/css/styles.css +++ b/static/css/styles.css @@ -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}} .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} +.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} diff --git a/static/js/app.js b/static/js/app.js index 9a27f00..42275dc 100644 --- a/static/js/app.js +++ b/static/js/app.js @@ -78,11 +78,17 @@ $('#theme').onclick = () => { try { localStorage.setItem('weread-theme', theme); } catch { toast('主题已切换,本次浏览有效。'); } }; -/* 封面:沿用设计稿的示意封面(4 种底色 + 书名短行) */ +/* 封面:优先显示微信读书返回的真实封面,加载失败时回退到示意封面 */ function cover(book, mini = false) { const short = book.short || book.title || ''; - if (mini) return ``; - return `
${esc(book.en || '')}${esc(short).replaceAll('\n', '
')}
${esc(book.author)}READING SPACE · 藏书
`; + const coverUrl = book.cover_url || (typeof book.cover === 'string' && /^https?:\/\//i.test(book.cover) ? book.cover : ''); + const coverClass = typeof book.cover === 'string' && !/^https?:\/\//i.test(book.cover) ? book.cover : ''; + const fallback = mini + ? `` + : `
${esc(book.en || '')}${esc(short).replaceAll('\n', '
')}
${esc(book.author)}READING SPACE · 藏书
`; + if (!coverUrl) return fallback; + const className = mini ? 'real-cover mini-real-cover' : 'real-cover'; + return `${esc(book.title)}`; } function scoreText(book) { return book.score ? `评分 ${Math.round(Number(book.score) * 10)}/100` : '暂无评分';