bookrank-ci commited on
Commit ·
f319792
1
Parent(s): dc1798d
sync: main@85021e6ae99893fae8d89ed2b60dbc7a93ef2ddb
Browse files- static/css/charts.css +33 -9
- static/dist/{app.2ZOMS567.min.css → app.PXLGYFCP.min.css} +0 -0
- static/dist/app.min.css +0 -0
- static/dist/{book-i18n.4e93f26b.min.js → book-i18n.a1de7517.min.js} +1 -1
- static/dist/book-i18n.min.js +1 -1
- static/dist/{index.521edec9.min.js → index.47804282.min.js} +10 -10
- static/dist/index.min.js +10 -10
- static/dist/manifest.json +3 -3
- static/js/book-i18n.js +3 -1
- static/js/index.js +5 -3
static/css/charts.css
CHANGED
|
@@ -442,9 +442,14 @@
|
|
| 442 |
text-align: left;
|
| 443 |
/* 唯一保留钳制的地方:紧凑模式是用户主动选择的密度档(按钮即「紧凑五列」),
|
| 444 |
5 列下每张卡仅约 250px,整段简介会把卡片拉成长条,与"紧凑"的语义相悖。
|
| 445 |
-
默认的「精选三列」不钳制,简介完整展示。
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 446 |
display: -webkit-box;
|
| 447 |
-
-webkit-line-clamp:
|
| 448 |
-webkit-box-orient: vertical;
|
| 449 |
overflow: hidden;
|
| 450 |
}
|
|
@@ -544,8 +549,9 @@
|
|
| 544 |
}
|
| 545 |
|
| 546 |
/* ---- 排版收口 v2 ---- */
|
| 547 |
-
/*
|
| 548 |
-
|
|
|
|
| 549 |
.charts-page .books-grid.bestseller-grid:not([data-grid-view="compact"]) .card:nth-child(n+4) .card-image .cover-weeks {
|
| 550 |
display: none;
|
| 551 |
}
|
|
@@ -558,19 +564,37 @@
|
|
| 558 |
.charts-page .books-grid.bestseller-grid:not([data-grid-view="compact"]) .card:nth-child(-n+3) .card-pub-isbn-item.weeks {
|
| 559 |
display: none;
|
| 560 |
}
|
| 561 |
-
/*
|
| 562 |
-
.charts-page .books-grid.bestseller-grid[data-grid-view="compact"] .card
|
|
|
|
|
|
|
|
|
|
|
|
|
| 563 |
.charts-page .books-grid.bestseller-grid:not([data-grid-view="compact"]) .card:nth-child(n+4) .card-image .cover-frame img {
|
| 564 |
height: 100%;
|
| 565 |
margin-top: 0;
|
| 566 |
}
|
| 567 |
-
/* 紧凑五列:画框加高,
|
| 568 |
.charts-page .books-grid.bestseller-grid[data-grid-view="compact"] .card .card-image {
|
| 569 |
-
height:
|
| 570 |
padding: 16px 20px 8px;
|
| 571 |
}
|
| 572 |
.charts-page .books-grid.bestseller-grid[data-grid-view="compact"] .card .cover-frame {
|
| 573 |
-
height:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 574 |
}
|
| 575 |
|
| 576 |
/* ---- 排版收尾 v3 ---- */
|
|
|
|
| 442 |
text-align: left;
|
| 443 |
/* 唯一保留钳制的地方:紧凑模式是用户主动选择的密度档(按钮即「紧凑五列」),
|
| 444 |
5 列下每张卡仅约 250px,整段简介会把卡片拉成长条,与"紧凑"的语义相悖。
|
| 445 |
+
默认的「精选三列」不钳制,简介完整展示。
|
| 446 |
+
2026-09-17:按需求把钳制从 3 行放宽到 5 行,并同步收小字号/行高 ——
|
| 447 |
+
3 行(13px×1.5)=58.5px 与 5 行(12px×1.45)=87px 仍然更高,但字更小、行更密,
|
| 448 |
+
同样的卡片宽度里能容纳的正文明显变多。 */
|
| 449 |
+
font-size: 12px;
|
| 450 |
+
line-height: 1.45;
|
| 451 |
display: -webkit-box;
|
| 452 |
+
-webkit-line-clamp: 5;
|
| 453 |
-webkit-box-orient: vertical;
|
| 454 |
overflow: hidden;
|
| 455 |
}
|
|
|
|
| 549 |
}
|
| 550 |
|
| 551 |
/* ---- 排版收口 v2 ---- */
|
| 552 |
+
/* 精选三列的通栏行:隐藏封面角上的胶囊,改用同行 chip。
|
| 553 |
+
2026-09-17:紧凑五列**不再**隐藏胶囊 —— 周数改回封面右上角(与精选三列一致),
|
| 554 |
+
见下方 [data-grid-view="compact"] 的 chip 隐藏规则。 */
|
| 555 |
.charts-page .books-grid.bestseller-grid:not([data-grid-view="compact"]) .card:nth-child(n+4) .card-image .cover-weeks {
|
| 556 |
display: none;
|
| 557 |
}
|
|
|
|
| 564 |
.charts-page .books-grid.bestseller-grid:not([data-grid-view="compact"]) .card:nth-child(-n+3) .card-pub-isbn-item.weeks {
|
| 565 |
display: none;
|
| 566 |
}
|
| 567 |
+
/* 紧凑五列:周数同样走封面右上角胶囊 → 隐藏 meta 行 chip,仍是一处一现 */
|
| 568 |
+
.charts-page .books-grid.bestseller-grid[data-grid-view="compact"] .card-pub-isbn-item.weeks {
|
| 569 |
+
display: none;
|
| 570 |
+
}
|
| 571 |
+
/* 精选三列的通栏行恢复满高封面;紧凑五列**保留** 20px 顶部预留带 ——
|
| 572 |
+
周数胶囊回到封面右上角后,需要一条不被封面图压住的落位带(与精选三列同构)。 */
|
| 573 |
.charts-page .books-grid.bestseller-grid:not([data-grid-view="compact"]) .card:nth-child(n+4) .card-image .cover-frame img {
|
| 574 |
height: 100%;
|
| 575 |
margin-top: 0;
|
| 576 |
}
|
| 577 |
+
/* 紧凑五列:画框加高,多出的 20px 补回预留带,封面尺寸不缩水 */
|
| 578 |
.charts-page .books-grid.bestseller-grid[data-grid-view="compact"] .card .card-image {
|
| 579 |
+
height: 214px;
|
| 580 |
padding: 16px 20px 8px;
|
| 581 |
}
|
| 582 |
.charts-page .books-grid.bestseller-grid[data-grid-view="compact"] .card .cover-frame {
|
| 583 |
+
height: 190px;
|
| 584 |
+
}
|
| 585 |
+
/* 五列更窄:胶囊收小一档并贴顶落在 20px 预留带内(覆盖 761px 断点里给外置胶囊留的 top:4px),
|
| 586 |
+
既不压封面、也不碰隔壁卡片 */
|
| 587 |
+
.charts-page .books-grid.bestseller-grid[data-grid-view="compact"] .card .card-image .cover-weeks {
|
| 588 |
+
top: 1px;
|
| 589 |
+
right: 0;
|
| 590 |
+
left: auto;
|
| 591 |
+
padding: 2px 0 3px 8px;
|
| 592 |
+
}
|
| 593 |
+
.charts-page .books-grid.bestseller-grid[data-grid-view="compact"] .card .cover-weeks-value strong {
|
| 594 |
+
font-size: 16px;
|
| 595 |
+
}
|
| 596 |
+
.charts-page .books-grid.bestseller-grid[data-grid-view="compact"] .card .cover-weeks-value > span {
|
| 597 |
+
font-size: 10px;
|
| 598 |
}
|
| 599 |
|
| 600 |
/* ---- 排版收尾 v3 ---- */
|
static/dist/{app.2ZOMS567.min.css → app.PXLGYFCP.min.css}
RENAMED
|
The diff for this file is too large to render.
See raw diff
|
|
|
static/dist/app.min.css
CHANGED
|
The diff for this file is too large to render.
See raw diff
|
|
|
static/dist/{book-i18n.4e93f26b.min.js → book-i18n.a1de7517.min.js}
RENAMED
|
@@ -1 +1 @@
|
|
| 1 |
-
var BookI18n=(function(){"use strict";var l=new Map,v=".card-title, .list-item-title, .book-title, .detail-title, .recommendation-title, .change-title",A=".card-desc, .list-item-desc, .book-description, .detail-description",b=".card-category-tag, .book-category, .list-item-meta .card-tag:first-child";function d(e){if(!e)return!1;var i=e.replace(/[-\s]/g,"");return/^\d+$/.test(i)&&(i.length===10||i.length===13)}function w(e){var i=e.isbn13||e.isbn10||"";if(!i)return null;var t=e.category_id||"",r,n;t&&typeof window<"u"&&window.CATEGORIES&&window.CATEGORIES.getLabel?(r=window.CATEGORIES.getLabel(t,"en"),n=window.CATEGORIES.getLabel(t,"zh")):(r=e.list_name||e.category_name||"Fiction",n=e.category_name||r);var a=e.title||"",s=e.title_zh||"";return d(a)&&(a=s||a),d(s)&&(s=a||s),{isbn:i,category_id:t,en:{title:a,description:e.description||"",category:r,details:e.details||""},zh:{title:s,description:e.description_zh||"",category:n,details:e.details_zh||""},_raw:e}}function z(e,i){if(e){var t=l.get(e),r=w(i);r&&(t?(r.zh.title&&!t.zh.title&&(t.zh.title=r.zh.title),r.zh.description&&!t.zh.description&&(t.zh.description=r.zh.description),r.zh.category&&!t.zh.category&&(t.zh.category=r.zh.category),r.zh.details&&!t.zh.details&&(t.zh.details=r.zh.details)):l.set(e,r))}}function T(e){if(Array.isArray(e))for(var i=0;i<e.length;i++){var t=e[i].isbn13||e[i].isbn10;t&&z(t,e[i])}}function g(e,i){var t=l.get(e);if(!t)return null;var r=t[i]||{},n=t.en,a=r.title||n.title;return d(a)&&(a=(i==="zh"?n.title:r.title)||a),{title:a,description:r.description||n.description,category:r.category||n.category,details:r.details||n.details}}function m(e,i,t){var r=l.get(e);r&&(r[i]||(r[i]={}),t.title&&!d(t.title)&&(r[i].title=t.title),t.description&&(r[i].description=t.description),t.category&&(r[i].category=t.category),t.details&&(r[i].details=t.details))}function q(e){if(Array.isArray(e))for(var i=0;i<e.length;i++){var t=e[i];!t||!t.isbn||m(t.isbn,t.language||"zh",t.data||{})}}function L(e){var i=[];return l.forEach(function(t,r){if(e!=="en"){var n=t[e]&&t[e].title&&t[e].title!==t.en.title;n||i.push(r)}}),i}function o(e,i,t){!e||i===void 0||(t&&i.length>t?e.textContent=i.substring(0,t)+"...":e.textContent=i)}function I(e,i){e&&(e.matches&&e.matches(v)?o(e,i):o(e.querySelector(v),i))}function O(e){for(var i=document.querySelectorAll('.detail-meta-grid .meta-label[data-i18n="'+e+'"]'),t=0;t<i.length;t++){var r=i[t].closest?i[t].closest(".meta-card"):null;if(r){var n=r.querySelector(".meta-value");if(n)return n}}return null}function R(e){if(l.size!==0){var i=document.querySelectorAll("[data-isbn]").length>0;if(i||l.size>1)l.forEach(function(c,u){var f=g(u,e);if(f)for(var _=document.querySelectorAll('[data-isbn="'+u+'"]'),h=0;h<_.length;h++){var y=_[h];I(y,f.title),o(y.querySelector(A),f.description
|
|
|
|
| 1 |
+
var BookI18n=(function(){"use strict";var l=new Map,v=".card-title, .list-item-title, .book-title, .detail-title, .recommendation-title, .change-title",A=".card-desc, .list-item-desc, .book-description, .detail-description",b=".card-category-tag, .book-category, .list-item-meta .card-tag:first-child";function d(e){if(!e)return!1;var i=e.replace(/[-\s]/g,"");return/^\d+$/.test(i)&&(i.length===10||i.length===13)}function w(e){var i=e.isbn13||e.isbn10||"";if(!i)return null;var t=e.category_id||"",r,n;t&&typeof window<"u"&&window.CATEGORIES&&window.CATEGORIES.getLabel?(r=window.CATEGORIES.getLabel(t,"en"),n=window.CATEGORIES.getLabel(t,"zh")):(r=e.list_name||e.category_name||"Fiction",n=e.category_name||r);var a=e.title||"",s=e.title_zh||"";return d(a)&&(a=s||a),d(s)&&(s=a||s),{isbn:i,category_id:t,en:{title:a,description:e.description||"",category:r,details:e.details||""},zh:{title:s,description:e.description_zh||"",category:n,details:e.details_zh||""},_raw:e}}function z(e,i){if(e){var t=l.get(e),r=w(i);r&&(t?(r.zh.title&&!t.zh.title&&(t.zh.title=r.zh.title),r.zh.description&&!t.zh.description&&(t.zh.description=r.zh.description),r.zh.category&&!t.zh.category&&(t.zh.category=r.zh.category),r.zh.details&&!t.zh.details&&(t.zh.details=r.zh.details)):l.set(e,r))}}function T(e){if(Array.isArray(e))for(var i=0;i<e.length;i++){var t=e[i].isbn13||e[i].isbn10;t&&z(t,e[i])}}function g(e,i){var t=l.get(e);if(!t)return null;var r=t[i]||{},n=t.en,a=r.title||n.title;return d(a)&&(a=(i==="zh"?n.title:r.title)||a),{title:a,description:r.description||n.description,category:r.category||n.category,details:r.details||n.details}}function m(e,i,t){var r=l.get(e);r&&(r[i]||(r[i]={}),t.title&&!d(t.title)&&(r[i].title=t.title),t.description&&(r[i].description=t.description),t.category&&(r[i].category=t.category),t.details&&(r[i].details=t.details))}function q(e){if(Array.isArray(e))for(var i=0;i<e.length;i++){var t=e[i];!t||!t.isbn||m(t.isbn,t.language||"zh",t.data||{})}}function L(e){var i=[];return l.forEach(function(t,r){if(e!=="en"){var n=t[e]&&t[e].title&&t[e].title!==t.en.title;n||i.push(r)}}),i}function o(e,i,t){!e||i===void 0||(t&&i.length>t?e.textContent=i.substring(0,t)+"...":e.textContent=i)}function I(e,i){e&&(e.matches&&e.matches(v)?o(e,i):o(e.querySelector(v),i))}function O(e){for(var i=document.querySelectorAll('.detail-meta-grid .meta-label[data-i18n="'+e+'"]'),t=0;t<i.length;t++){var r=i[t].closest?i[t].closest(".meta-card"):null;if(r){var n=r.querySelector(".meta-value");if(n)return n}}return null}function R(e){if(l.size!==0){var i=document.querySelectorAll("[data-isbn]").length>0;if(i||l.size>1)l.forEach(function(c,u){var f=g(u,e);if(f)for(var _=document.querySelectorAll('[data-isbn="'+u+'"]'),h=0;h<_.length;h++){var y=_[h];I(y,f.title),o(y.querySelector(A),f.description),o(y.querySelector(b),f.category)}});else if(l.size===1){var t=null;l.forEach(function(c){t=c});var r=g(t.isbn,e);if(!r)return;var n=document.querySelector(".detail-title");n&&o(n,r.title);var a=document.querySelector(".detail-title-en");a&&(e==="zh"&&r.title!==t.en.title?(a.style.display="block",a.textContent=t.en.title):a.style.display="none");var s=document.querySelector("#panel-description .zh-description"),p=document.querySelector("#panel-description #desc-en, #panel-description .lang-toggle-content");if(s&&p){var S=!0;e==="zh"&&r.description&&r.description!==t.en.description?(s.textContent=r.description,s.style.display="block",S=!1):s.style.display="none",p.style.display="",p.classList.toggle("visible",S)}var C=document.querySelector(".detail-meta-grid .meta-value[data-cat-zh][data-cat-en]")||O("book_category");C&&o(C,r.category);var G=document.querySelectorAll(".lang-toggle-btn");G.forEach(function(c){var u=c.querySelector(".toggle-text");u&&(u.textContent=e==="zh"?"\u67E5\u770B\u82F1\u6587\u539F\u6587":"View Original"),c.style.display=e==="zh"?"":"none"})}window.dispatchEvent(new CustomEvent("booklanguagechange",{detail:{language:e}}))}}function B(){l.clear()}function x(){return l.size}function E(e){if(!(e!=="zh"&&e!=="en"))for(var i=document.querySelectorAll("[data-pub-name-zh]"),t=0;t<i.length;t++){var r=i[t],n=r.getAttribute("data-pub-name-zh")||"",a=r.getAttribute("data-pub-name-en")||n;r.textContent=e==="en"?a:n}}return{register:z,registerAll:T,get:g,updateTranslation:m,updateBatch:q,getMissingTranslations:L,applyLanguage:R,applyPublisherLanguage:E,clear:B,size:x}})();window.BookI18n=BookI18n;
|
static/dist/book-i18n.min.js
CHANGED
|
@@ -1 +1 @@
|
|
| 1 |
-
var BookI18n=(function(){"use strict";var l=new Map,v=".card-title, .list-item-title, .book-title, .detail-title, .recommendation-title, .change-title",A=".card-desc, .list-item-desc, .book-description, .detail-description",b=".card-category-tag, .book-category, .list-item-meta .card-tag:first-child";function d(e){if(!e)return!1;var i=e.replace(/[-\s]/g,"");return/^\d+$/.test(i)&&(i.length===10||i.length===13)}function w(e){var i=e.isbn13||e.isbn10||"";if(!i)return null;var t=e.category_id||"",r,n;t&&typeof window<"u"&&window.CATEGORIES&&window.CATEGORIES.getLabel?(r=window.CATEGORIES.getLabel(t,"en"),n=window.CATEGORIES.getLabel(t,"zh")):(r=e.list_name||e.category_name||"Fiction",n=e.category_name||r);var a=e.title||"",s=e.title_zh||"";return d(a)&&(a=s||a),d(s)&&(s=a||s),{isbn:i,category_id:t,en:{title:a,description:e.description||"",category:r,details:e.details||""},zh:{title:s,description:e.description_zh||"",category:n,details:e.details_zh||""},_raw:e}}function z(e,i){if(e){var t=l.get(e),r=w(i);r&&(t?(r.zh.title&&!t.zh.title&&(t.zh.title=r.zh.title),r.zh.description&&!t.zh.description&&(t.zh.description=r.zh.description),r.zh.category&&!t.zh.category&&(t.zh.category=r.zh.category),r.zh.details&&!t.zh.details&&(t.zh.details=r.zh.details)):l.set(e,r))}}function T(e){if(Array.isArray(e))for(var i=0;i<e.length;i++){var t=e[i].isbn13||e[i].isbn10;t&&z(t,e[i])}}function g(e,i){var t=l.get(e);if(!t)return null;var r=t[i]||{},n=t.en,a=r.title||n.title;return d(a)&&(a=(i==="zh"?n.title:r.title)||a),{title:a,description:r.description||n.description,category:r.category||n.category,details:r.details||n.details}}function m(e,i,t){var r=l.get(e);r&&(r[i]||(r[i]={}),t.title&&!d(t.title)&&(r[i].title=t.title),t.description&&(r[i].description=t.description),t.category&&(r[i].category=t.category),t.details&&(r[i].details=t.details))}function q(e){if(Array.isArray(e))for(var i=0;i<e.length;i++){var t=e[i];!t||!t.isbn||m(t.isbn,t.language||"zh",t.data||{})}}function L(e){var i=[];return l.forEach(function(t,r){if(e!=="en"){var n=t[e]&&t[e].title&&t[e].title!==t.en.title;n||i.push(r)}}),i}function o(e,i,t){!e||i===void 0||(t&&i.length>t?e.textContent=i.substring(0,t)+"...":e.textContent=i)}function I(e,i){e&&(e.matches&&e.matches(v)?o(e,i):o(e.querySelector(v),i))}function O(e){for(var i=document.querySelectorAll('.detail-meta-grid .meta-label[data-i18n="'+e+'"]'),t=0;t<i.length;t++){var r=i[t].closest?i[t].closest(".meta-card"):null;if(r){var n=r.querySelector(".meta-value");if(n)return n}}return null}function R(e){if(l.size!==0){var i=document.querySelectorAll("[data-isbn]").length>0;if(i||l.size>1)l.forEach(function(c,u){var f=g(u,e);if(f)for(var _=document.querySelectorAll('[data-isbn="'+u+'"]'),h=0;h<_.length;h++){var y=_[h];I(y,f.title),o(y.querySelector(A),f.description
|
|
|
|
| 1 |
+
var BookI18n=(function(){"use strict";var l=new Map,v=".card-title, .list-item-title, .book-title, .detail-title, .recommendation-title, .change-title",A=".card-desc, .list-item-desc, .book-description, .detail-description",b=".card-category-tag, .book-category, .list-item-meta .card-tag:first-child";function d(e){if(!e)return!1;var i=e.replace(/[-\s]/g,"");return/^\d+$/.test(i)&&(i.length===10||i.length===13)}function w(e){var i=e.isbn13||e.isbn10||"";if(!i)return null;var t=e.category_id||"",r,n;t&&typeof window<"u"&&window.CATEGORIES&&window.CATEGORIES.getLabel?(r=window.CATEGORIES.getLabel(t,"en"),n=window.CATEGORIES.getLabel(t,"zh")):(r=e.list_name||e.category_name||"Fiction",n=e.category_name||r);var a=e.title||"",s=e.title_zh||"";return d(a)&&(a=s||a),d(s)&&(s=a||s),{isbn:i,category_id:t,en:{title:a,description:e.description||"",category:r,details:e.details||""},zh:{title:s,description:e.description_zh||"",category:n,details:e.details_zh||""},_raw:e}}function z(e,i){if(e){var t=l.get(e),r=w(i);r&&(t?(r.zh.title&&!t.zh.title&&(t.zh.title=r.zh.title),r.zh.description&&!t.zh.description&&(t.zh.description=r.zh.description),r.zh.category&&!t.zh.category&&(t.zh.category=r.zh.category),r.zh.details&&!t.zh.details&&(t.zh.details=r.zh.details)):l.set(e,r))}}function T(e){if(Array.isArray(e))for(var i=0;i<e.length;i++){var t=e[i].isbn13||e[i].isbn10;t&&z(t,e[i])}}function g(e,i){var t=l.get(e);if(!t)return null;var r=t[i]||{},n=t.en,a=r.title||n.title;return d(a)&&(a=(i==="zh"?n.title:r.title)||a),{title:a,description:r.description||n.description,category:r.category||n.category,details:r.details||n.details}}function m(e,i,t){var r=l.get(e);r&&(r[i]||(r[i]={}),t.title&&!d(t.title)&&(r[i].title=t.title),t.description&&(r[i].description=t.description),t.category&&(r[i].category=t.category),t.details&&(r[i].details=t.details))}function q(e){if(Array.isArray(e))for(var i=0;i<e.length;i++){var t=e[i];!t||!t.isbn||m(t.isbn,t.language||"zh",t.data||{})}}function L(e){var i=[];return l.forEach(function(t,r){if(e!=="en"){var n=t[e]&&t[e].title&&t[e].title!==t.en.title;n||i.push(r)}}),i}function o(e,i,t){!e||i===void 0||(t&&i.length>t?e.textContent=i.substring(0,t)+"...":e.textContent=i)}function I(e,i){e&&(e.matches&&e.matches(v)?o(e,i):o(e.querySelector(v),i))}function O(e){for(var i=document.querySelectorAll('.detail-meta-grid .meta-label[data-i18n="'+e+'"]'),t=0;t<i.length;t++){var r=i[t].closest?i[t].closest(".meta-card"):null;if(r){var n=r.querySelector(".meta-value");if(n)return n}}return null}function R(e){if(l.size!==0){var i=document.querySelectorAll("[data-isbn]").length>0;if(i||l.size>1)l.forEach(function(c,u){var f=g(u,e);if(f)for(var _=document.querySelectorAll('[data-isbn="'+u+'"]'),h=0;h<_.length;h++){var y=_[h];I(y,f.title),o(y.querySelector(A),f.description),o(y.querySelector(b),f.category)}});else if(l.size===1){var t=null;l.forEach(function(c){t=c});var r=g(t.isbn,e);if(!r)return;var n=document.querySelector(".detail-title");n&&o(n,r.title);var a=document.querySelector(".detail-title-en");a&&(e==="zh"&&r.title!==t.en.title?(a.style.display="block",a.textContent=t.en.title):a.style.display="none");var s=document.querySelector("#panel-description .zh-description"),p=document.querySelector("#panel-description #desc-en, #panel-description .lang-toggle-content");if(s&&p){var S=!0;e==="zh"&&r.description&&r.description!==t.en.description?(s.textContent=r.description,s.style.display="block",S=!1):s.style.display="none",p.style.display="",p.classList.toggle("visible",S)}var C=document.querySelector(".detail-meta-grid .meta-value[data-cat-zh][data-cat-en]")||O("book_category");C&&o(C,r.category);var G=document.querySelectorAll(".lang-toggle-btn");G.forEach(function(c){var u=c.querySelector(".toggle-text");u&&(u.textContent=e==="zh"?"\u67E5\u770B\u82F1\u6587\u539F\u6587":"View Original"),c.style.display=e==="zh"?"":"none"})}window.dispatchEvent(new CustomEvent("booklanguagechange",{detail:{language:e}}))}}function B(){l.clear()}function x(){return l.size}function E(e){if(!(e!=="zh"&&e!=="en"))for(var i=document.querySelectorAll("[data-pub-name-zh]"),t=0;t<i.length;t++){var r=i[t],n=r.getAttribute("data-pub-name-zh")||"",a=r.getAttribute("data-pub-name-en")||n;r.textContent=e==="en"?a:n}}return{register:z,registerAll:T,get:g,updateTranslation:m,updateBatch:q,getMissingTranslations:L,applyLanguage:R,applyPublisherLanguage:E,clear:B,size:x}})();window.BookI18n=BookI18n;
|
static/dist/{index.521edec9.min.js → index.47804282.min.js}
RENAMED
|
@@ -12,19 +12,19 @@ let booksData=[],currentCategory="";(function(){var n=document.getElementById("i
|
|
| 12 |
<svg class="icon" width="16" height="16"><use href="#icon-clock"/></svg>
|
| 13 |
<span>${esc(c.query)}</span>
|
| 14 |
<svg class="icon delete-history" width="14" height="14" data-delete-query="${esc(c.query)}"><use href="#icon-x"/></svg>
|
| 15 |
-
</li>`}),i+="</ul>",e.innerHTML=i,e.style.display="block"}else e.style.display="none"}function deleteHistoryItem(e){try{let n=JSON.parse(localStorage.getItem("bookrank_search_history")||"[]");n=n.filter(a=>a.query!==e),localStorage.setItem("bookrank_search_history",JSON.stringify(n)),renderSearchSuggestions()}catch(n){console.error("\u5220\u9664\u641C\u7D22\u5386\u53F2\u5931\u8D25:",n)}}function applySearch(e){const n=document.getElementById("search-input");n&&(n.value=e);const a=document.getElementById("search-suggestions");a&&(a.style.display="none"),saveSearchHistory(e),applyFilters()}function toggleFavorite(e,n){if(!n)return;let a=JSON.parse(localStorage.getItem("bookrank_favorites")||"[]");const s=a.indexOf(n);s>-1?(a.splice(s,1),e.classList.remove("active"),e.setAttribute("aria-pressed","false"),showToast("\u5DF2\u53D6\u6D88\u6536\u85CF","info")):(a.push(n),e.classList.add("active"),e.setAttribute("aria-pressed","true"),showToast("\u5DF2\u6DFB\u52A0\u5230\u6536\u85CF","success")),localStorage.setItem("bookrank_favorites",JSON.stringify(a))}function shareBook(e,n){if(navigator.share)navigator.share({title:`${e} - BookRank`,text:`\u6211\u5728 BookRank \u53D1\u73B0\u4E86\u597D\u4E66: ${e} (${n})`,url:window.location.href}).catch(()=>{});else{const a=`${e} - ${n}`;navigator.clipboard.writeText(a).then(()=>{showToast("\u5DF2\u590D\u5236\u5230\u526A\u8D34\u677F","success")}).catch(()=>{showToast("\u590D\u5236\u5931\u8D25","error")})}}function getCategoryLabel(e,n){return typeof window<"u"&&window.CATEGORIES&&window.CATEGORIES.getLabel?window.CATEGORIES.getLabel(e,n):e}function buildSkeletonCardsHTML(e){for(var n=e||8,a="",s=0;s<n;s++)a+='<article class="card card-skeleton" aria-hidden="true"> <div class="skeleton skeleton-image"></div> <div class="skeleton-content"> <div class="skeleton skeleton-title"></div> <div class="skeleton skeleton-author"></div> <div class="skeleton skeleton-tag"></div> </div></article>';return a}function showSkeleton(){var e=document.getElementById("books-grid");e&&(e.innerHTML=buildSkeletonCardsHTML(8))}function hideSkeleton(){var e=document.querySelectorAll(".card-skeleton");e.forEach(function(n){n.parentNode&&n.parentNode.removeChild(n)})}function showLoading(e){const n=document.getElementById("loading-overlay"),a=document.getElementById("loading-text");n&&(n.style.display="flex"),a&&e&&(a.textContent=e)}function hideLoading(){const e=document.getElementById("loading-overlay");e&&(e.style.display="none")}document.addEventListener("DOMContentLoaded",function(){updateLanguageButtons(currentLanguage),currentLanguage==="zh"&&typeof BookI18n<"u"&&BookI18n.applyLanguage("zh")});const _memoryCategoryCache=new Map,categoryCache={get:function(e){if(_memoryCategoryCache.has(e))return _memoryCategoryCache.get(e);try{const n=`bookrank_category_${e}`,a=localStorage.getItem(n);if(a){const s=JSON.parse(a),i=["updateTime","updateFrequency","listPublishedDate"].every(c=>Object.prototype.hasOwnProperty.call(s,c));if(Date.now()-s.timestamp<864e5&&Array.isArray(s.books)&&i)return _memoryCategoryCache.set(e,s),s;localStorage.removeItem(n)}}catch{}return null},set:function(e,n,a,s,i){const c={timestamp:Date.now(),books:n,updateTime:a,updateFrequency:s,listPublishedDate:i};_memoryCategoryCache.set(e,c);try{const l=`bookrank_category_${e}`;localStorage.setItem(l,JSON.stringify(c))}catch{}}};async function changeCategory(e){if(e===window.currentCategory)return;const n=categoryCache.get(e);if(n&&Array.isArray(n.books)&&n.books.length>0){const a=n.books;window.currentCategory=e,window.booksData=a,currentCategory=e,booksData=a,typeof BookI18n<"u"&&(BookI18n.clear(),BookI18n.registerAll(a)),updateBooksOnPage(a,e,n.updateTime,n.updateFrequency,n.listPublishedDate);const s=new URLSearchParams;s.set("category",e);const i=window.location.pathname+"?"+s.toString();window.history.pushState({category:e},"",i),currentLanguage==="zh"&&typeof BookI18n<"u"&&BookI18n.applyLanguage("zh");return}showSkeleton(),showLoading("\u52A0\u8F7D\u4E2D...");try{const a=await fetch(`/api/category-books?category=${encodeURIComponent(e)}`,{headers:{"X-Requested-With":"XMLHttpRequest"}});if(!a.ok)throw new Error("\u7F51\u7EDC\u8BF7\u6C42\u5931\u8D25");const s=await a.json();if(!s.success)throw new Error(s.message||s.error||"\u52A0\u8F7D\u5931\u8D25");const i=s.data||s,c=i.books||[];categoryCache.set(e,c,i.update_time,i.update_frequency,i.list_published_date),window.currentCategory=e,window.booksData=c,currentCategory=e,booksData=c,typeof BookI18n<"u"&&(BookI18n.clear(),BookI18n.registerAll(c)),updateBooksOnPage(c,e,i.update_time,i.update_frequency,i.list_published_date);const l=new URLSearchParams;l.set("category",e);const r=window.location.pathname+"?"+l.toString();window.history.pushState({category:e},"",r),hideLoading(),currentLanguage==="zh"&&typeof BookI18n<"u"&&BookI18n.applyLanguage("zh")}catch(a){console.error("\u5206\u7C7B\u5207\u6362\u5931\u8D25:",a),showToast(t("toast_category_load_failed",currentLanguage),"error"),hideSkeleton(),hideLoading(),document.getElementById("category-select").value=window.currentCategory}}function resolveCategoryLabel(e,n,a){return a==="zh"?e.category_name||(typeof getCategoryLabel=="function"?getCategoryLabel(n,"zh"):null)||"\u865A\u6784\u7C7B":e.list_name||e.category_name||(typeof getCategoryLabel=="function"?getCategoryLabel(n,"en"):null)||"Fiction"}function rerenderCurrentBooks(e){var n=booksData;if(!Array.isArray(n)||n.length===0){var a=document.getElementById("initial-books-data");if(a)try{n=JSON.parse(a.textContent||"[]")}catch{n=[]}}if(!(!Array.isArray(n)||n.length===0)){var s=currentCategory||window.APP_CONFIG&&window.APP_CONFIG.currentCategory||"hardcover-fiction",i=document.querySelector(".page-subtitle time"),c=i?i.getAttribute("datetime"):null;try{updateBooksOnPage(n,s,c)}catch(l){console.error("[rerenderCurrentBooks] FAILED:",l.message)}}}function updateCategorySelectOptions(e){var n=document.getElementById("category-select");!n||typeof getCategoryLabel!="function"||Array.from(n.options).forEach(function(a){a.textContent=getCategoryLabel(a.value,e)})}function formatLocalTime(e,n){if(!e)return"";if(n==="zh")return e;var a=String(e).match(/^(\d{4})-(\d{2})-(\d{2})\s+(\d{1,2}):(\d{2})(?::(\d{2}))?$/);if(!a)return e;var s=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],i=a[1],c=s[parseInt(a[2],10)-1]||a[2],l=parseInt(a[3],10),r=parseInt(a[4],10),f=a[5],
|
| 16 |
<span class="cover-weeks-value"><strong>${a}</strong><span>${esc(c)}</span></span>
|
| 17 |
-
</span>`}function updateBooksOnPage(e,n,a,s,i){const c=currentLanguage==="zh",l=window.APP_CONFIG.defaultCover,r=currentLanguage,f=document.getElementById("category-select");f&&(f.value=n);const
|
| 18 |
<article class="card card-animate"
|
| 19 |
data-isbn="${esc(o.isbn13||o.isbn10||"")}"
|
| 20 |
-
data-index="${
|
| 21 |
data-category="${esc(d)}"
|
| 22 |
-
aria-label="${esc(
|
| 23 |
<a class="card-link" href="${y}">
|
| 24 |
<div class="card-image">
|
| 25 |
<div class="cover-frame">
|
| 26 |
-
<img src="${esc(coverToSrc(
|
| 27 |
-
alt="${esc(t("card_cover_alt",r,{title:
|
| 28 |
loading="lazy"
|
| 29 |
width="280"
|
| 30 |
height="240"
|
|
@@ -32,7 +32,7 @@ let booksData=[],currentCategory="";(function(){var n=document.getElementById("i
|
|
| 32 |
data-fallback="${l}">
|
| 33 |
${renderCoverWeeks(o,r)}
|
| 34 |
</div>
|
| 35 |
-
<span class="card-category-tag">${esc(
|
| 36 |
<span class="card-badge ${u===1?"gold":u===2?"silver":u===3?"bronze":"other"}"
|
| 37 |
aria-label="${esc(t("card_badge_aria",r,{n:u}))}">
|
| 38 |
${u}
|
|
@@ -40,7 +40,7 @@ let booksData=[],currentCategory="";(function(){var n=document.getElementById("i
|
|
| 40 |
${renderRankChange(o,u,r,"rank-change")}
|
| 41 |
</div>
|
| 42 |
<div class="card-content">
|
| 43 |
-
<h3 class="card-title" title="${esc(
|
| 44 |
<p class="card-author">${esc(o.author)}</p>
|
| 45 |
${o.publisher||o.isbn13||o.isbn10||o.weeks_on_list?`
|
| 46 |
<p class="card-pub-isbn">
|
|
@@ -48,8 +48,8 @@ let booksData=[],currentCategory="";(function(){var n=document.getElementById("i
|
|
| 48 |
${o.isbn13?`<span class="card-pub-isbn-item isbn" title="ISBN-13: ${esc(o.isbn13)}">${esc(o.isbn13)}</span>`:o.isbn10?`<span class="card-pub-isbn-item isbn" title="ISBN-10: ${esc(o.isbn10)}">${esc(o.isbn10)}</span>`:""}
|
| 49 |
${o.weeks_on_list?`<span class="card-pub-isbn-item weeks" title="${esc(t("weeks_on_list",r))}">${esc(t("card_weeks_suffix",r,{n:o.weeks_on_list}))}</span>`:""}
|
| 50 |
</p>`:""}
|
| 51 |
-
${
|
| 52 |
</div>
|
| 53 |
</a>
|
| 54 |
</article>
|
| 55 |
-
`}).join(""));const g=document.querySelector(".export-actions-bar");if(g){const o=g.querySelector(".export-info");if(o){const
|
|
|
|
| 12 |
<svg class="icon" width="16" height="16"><use href="#icon-clock"/></svg>
|
| 13 |
<span>${esc(c.query)}</span>
|
| 14 |
<svg class="icon delete-history" width="14" height="14" data-delete-query="${esc(c.query)}"><use href="#icon-x"/></svg>
|
| 15 |
+
</li>`}),i+="</ul>",e.innerHTML=i,e.style.display="block"}else e.style.display="none"}function deleteHistoryItem(e){try{let n=JSON.parse(localStorage.getItem("bookrank_search_history")||"[]");n=n.filter(a=>a.query!==e),localStorage.setItem("bookrank_search_history",JSON.stringify(n)),renderSearchSuggestions()}catch(n){console.error("\u5220\u9664\u641C\u7D22\u5386\u53F2\u5931\u8D25:",n)}}function applySearch(e){const n=document.getElementById("search-input");n&&(n.value=e);const a=document.getElementById("search-suggestions");a&&(a.style.display="none"),saveSearchHistory(e),applyFilters()}function toggleFavorite(e,n){if(!n)return;let a=JSON.parse(localStorage.getItem("bookrank_favorites")||"[]");const s=a.indexOf(n);s>-1?(a.splice(s,1),e.classList.remove("active"),e.setAttribute("aria-pressed","false"),showToast("\u5DF2\u53D6\u6D88\u6536\u85CF","info")):(a.push(n),e.classList.add("active"),e.setAttribute("aria-pressed","true"),showToast("\u5DF2\u6DFB\u52A0\u5230\u6536\u85CF","success")),localStorage.setItem("bookrank_favorites",JSON.stringify(a))}function shareBook(e,n){if(navigator.share)navigator.share({title:`${e} - BookRank`,text:`\u6211\u5728 BookRank \u53D1\u73B0\u4E86\u597D\u4E66: ${e} (${n})`,url:window.location.href}).catch(()=>{});else{const a=`${e} - ${n}`;navigator.clipboard.writeText(a).then(()=>{showToast("\u5DF2\u590D\u5236\u5230\u526A\u8D34\u677F","success")}).catch(()=>{showToast("\u590D\u5236\u5931\u8D25","error")})}}function getCategoryLabel(e,n){return typeof window<"u"&&window.CATEGORIES&&window.CATEGORIES.getLabel?window.CATEGORIES.getLabel(e,n):e}function buildSkeletonCardsHTML(e){for(var n=e||8,a="",s=0;s<n;s++)a+='<article class="card card-skeleton" aria-hidden="true"> <div class="skeleton skeleton-image"></div> <div class="skeleton-content"> <div class="skeleton skeleton-title"></div> <div class="skeleton skeleton-author"></div> <div class="skeleton skeleton-tag"></div> </div></article>';return a}function showSkeleton(){var e=document.getElementById("books-grid");e&&(e.innerHTML=buildSkeletonCardsHTML(8))}function hideSkeleton(){var e=document.querySelectorAll(".card-skeleton");e.forEach(function(n){n.parentNode&&n.parentNode.removeChild(n)})}function showLoading(e){const n=document.getElementById("loading-overlay"),a=document.getElementById("loading-text");n&&(n.style.display="flex"),a&&e&&(a.textContent=e)}function hideLoading(){const e=document.getElementById("loading-overlay");e&&(e.style.display="none")}document.addEventListener("DOMContentLoaded",function(){updateLanguageButtons(currentLanguage),currentLanguage==="zh"&&typeof BookI18n<"u"&&BookI18n.applyLanguage("zh")});const _memoryCategoryCache=new Map,categoryCache={get:function(e){if(_memoryCategoryCache.has(e))return _memoryCategoryCache.get(e);try{const n=`bookrank_category_${e}`,a=localStorage.getItem(n);if(a){const s=JSON.parse(a),i=["updateTime","updateFrequency","listPublishedDate"].every(c=>Object.prototype.hasOwnProperty.call(s,c));if(Date.now()-s.timestamp<864e5&&Array.isArray(s.books)&&i)return _memoryCategoryCache.set(e,s),s;localStorage.removeItem(n)}}catch{}return null},set:function(e,n,a,s,i){const c={timestamp:Date.now(),books:n,updateTime:a,updateFrequency:s,listPublishedDate:i};_memoryCategoryCache.set(e,c);try{const l=`bookrank_category_${e}`;localStorage.setItem(l,JSON.stringify(c))}catch{}}};async function changeCategory(e){if(e===window.currentCategory)return;const n=categoryCache.get(e);if(n&&Array.isArray(n.books)&&n.books.length>0){const a=n.books;window.currentCategory=e,window.booksData=a,currentCategory=e,booksData=a,typeof BookI18n<"u"&&(BookI18n.clear(),BookI18n.registerAll(a)),updateBooksOnPage(a,e,n.updateTime,n.updateFrequency,n.listPublishedDate);const s=new URLSearchParams;s.set("category",e);const i=window.location.pathname+"?"+s.toString();window.history.pushState({category:e},"",i),currentLanguage==="zh"&&typeof BookI18n<"u"&&BookI18n.applyLanguage("zh");return}showSkeleton(),showLoading("\u52A0\u8F7D\u4E2D...");try{const a=await fetch(`/api/category-books?category=${encodeURIComponent(e)}`,{headers:{"X-Requested-With":"XMLHttpRequest"}});if(!a.ok)throw new Error("\u7F51\u7EDC\u8BF7\u6C42\u5931\u8D25");const s=await a.json();if(!s.success)throw new Error(s.message||s.error||"\u52A0\u8F7D\u5931\u8D25");const i=s.data||s,c=i.books||[];categoryCache.set(e,c,i.update_time,i.update_frequency,i.list_published_date),window.currentCategory=e,window.booksData=c,currentCategory=e,booksData=c,typeof BookI18n<"u"&&(BookI18n.clear(),BookI18n.registerAll(c)),updateBooksOnPage(c,e,i.update_time,i.update_frequency,i.list_published_date);const l=new URLSearchParams;l.set("category",e);const r=window.location.pathname+"?"+l.toString();window.history.pushState({category:e},"",r),hideLoading(),currentLanguage==="zh"&&typeof BookI18n<"u"&&BookI18n.applyLanguage("zh")}catch(a){console.error("\u5206\u7C7B\u5207\u6362\u5931\u8D25:",a),showToast(t("toast_category_load_failed",currentLanguage),"error"),hideSkeleton(),hideLoading(),document.getElementById("category-select").value=window.currentCategory}}function resolveCategoryLabel(e,n,a){return a==="zh"?e.category_name||(typeof getCategoryLabel=="function"?getCategoryLabel(n,"zh"):null)||"\u865A\u6784\u7C7B":e.list_name||e.category_name||(typeof getCategoryLabel=="function"?getCategoryLabel(n,"en"):null)||"Fiction"}function rerenderCurrentBooks(e){var n=booksData;if(!Array.isArray(n)||n.length===0){var a=document.getElementById("initial-books-data");if(a)try{n=JSON.parse(a.textContent||"[]")}catch{n=[]}}if(!(!Array.isArray(n)||n.length===0)){var s=currentCategory||window.APP_CONFIG&&window.APP_CONFIG.currentCategory||"hardcover-fiction",i=document.querySelector(".page-subtitle time"),c=i?i.getAttribute("datetime"):null;try{updateBooksOnPage(n,s,c)}catch(l){console.error("[rerenderCurrentBooks] FAILED:",l.message)}}}function updateCategorySelectOptions(e){var n=document.getElementById("category-select");!n||typeof getCategoryLabel!="function"||Array.from(n.options).forEach(function(a){a.textContent=getCategoryLabel(a.value,e)})}function formatLocalTime(e,n){if(!e)return"";if(n==="zh")return e;var a=String(e).match(/^(\d{4})-(\d{2})-(\d{2})\s+(\d{1,2}):(\d{2})(?::(\d{2}))?$/);if(!a)return e;var s=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],i=a[1],c=s[parseInt(a[2],10)-1]||a[2],l=parseInt(a[3],10),r=parseInt(a[4],10),f=a[5],m=r>=12?"PM":"AM",w=r%12||12;return c+" "+l+", "+i+" "+w+":"+f+" "+m}function getCategoryUpdateFrequency(e,n){return n?String(n).toLowerCase():(window.APP_CONFIG&&Array.isArray(window.APP_CONFIG.monthlyCategories)?window.APP_CONFIG.monthlyCategories:[]).includes(e)?"monthly":"weekly"}function getListPublishedDate(e,n){if(n)return n;if(!Array.isArray(e))return"";const a=e.find(s=>s&&s.published_date&&s.published_date!=="Unknown");return a?a.published_date:""}function updateMonthlyListHint(e,n,a,s,i){const c=document.getElementById("monthly-list-hint");if(!c)return;if(getCategoryUpdateFrequency(e,a)!=="monthly"){c.hidden=!0,c.textContent="";return}const r=getListPublishedDate(n,s);c.textContent=r?t("monthly_list_with_date",i,{date:r}):t("monthly_list",i),c.hidden=!1}function renderRankChange(e,n,a,s){const i=Number(e.previous_rank??e.rank_last_week??0);if(i>0){const l=i-n;if(!l)return"";const r=l>0?"up":"down",f=t(l>0?"card_rank_up_aria":"card_rank_down_aria",a,{n:Math.abs(l)});return`<span class="${s} ${r}" aria-label="${esc(f)}">${l>0?"+":""}${l}</span>`}const c=Number(e.weeks_on_list)||0;return e.is_new??(i===0&&c===1)?`<span class="${s} new" aria-label="${esc(t("card_new_aria",a))}">${esc(t("card_new_badge",a))}</span>`:e.is_returning??(i===0&&c>1)?`<span class="${s} new" aria-label="${a==="zh"?"\u91CD\u8FD4\u699C\u5355":"Returning to the list"}">${a==="zh"?"\u91CD\u8FD4":"RETURN"}</span>`:""}function renderCoverWeeks(e,n){const a=Number(e.weeks_on_list)||0;if(a<=0)return"";const s=t("weeks_on_list",n),c=t("card_weeks_suffix",n,{n:a}).replace(String(a),"").trim();return`<span class="cover-weeks" role="img" aria-label="${esc(s)}: ${a}${esc(c)}">
|
| 16 |
<span class="cover-weeks-value"><strong>${a}</strong><span>${esc(c)}</span></span>
|
| 17 |
+
</span>`}function updateBooksOnPage(e,n,a,s,i){const c=currentLanguage==="zh",l=window.APP_CONFIG.defaultCover,r=currentLanguage,f=document.getElementById("category-select");f&&(f.value=n);const m=document.querySelector(".page-subtitle time");if(m){m.setAttribute("datetime",a||"");var w=formatLocalTime(a,r);m.textContent=w?t("time_updated_at",r,{time:w}):t("time_just_now",r)}updateMonthlyListHint(n,e,s,i,r);const I=document.getElementById("books-grid");I&&(I.innerHTML=e.map((o,v)=>{const u=Number(o.rank)||v+1,h=o.source_index??u-1,d=o.source_category||n,y=`/book/${encodeURIComponent(h)}?category=${encodeURIComponent(d)}`,_=o.cover&&o.cover!==l?o.cover:o._original_cover||l,p=c&&o.title_zh||o.title,k=c?o.description_zh||o.description||"":o.description||"",b=resolveCategoryLabel(o,n,r),C=coverToSrc(o._original_cover);return`
|
| 18 |
<article class="card card-animate"
|
| 19 |
data-isbn="${esc(o.isbn13||o.isbn10||"")}"
|
| 20 |
+
data-index="${h}"
|
| 21 |
data-category="${esc(d)}"
|
| 22 |
+
aria-label="${esc(p)} - ${esc(t("card_rank_aria",r,{n:u}))}">
|
| 23 |
<a class="card-link" href="${y}">
|
| 24 |
<div class="card-image">
|
| 25 |
<div class="cover-frame">
|
| 26 |
+
<img src="${esc(coverToSrc(_)||l)}"
|
| 27 |
+
alt="${esc(t("card_cover_alt",r,{title:p}))}"
|
| 28 |
loading="lazy"
|
| 29 |
width="280"
|
| 30 |
height="240"
|
|
|
|
| 32 |
data-fallback="${l}">
|
| 33 |
${renderCoverWeeks(o,r)}
|
| 34 |
</div>
|
| 35 |
+
<span class="card-category-tag">${esc(b)}</span>
|
| 36 |
<span class="card-badge ${u===1?"gold":u===2?"silver":u===3?"bronze":"other"}"
|
| 37 |
aria-label="${esc(t("card_badge_aria",r,{n:u}))}">
|
| 38 |
${u}
|
|
|
|
| 40 |
${renderRankChange(o,u,r,"rank-change")}
|
| 41 |
</div>
|
| 42 |
<div class="card-content">
|
| 43 |
+
<h3 class="card-title" title="${esc(p)}">${esc(p)}</h3>
|
| 44 |
<p class="card-author">${esc(o.author)}</p>
|
| 45 |
${o.publisher||o.isbn13||o.isbn10||o.weeks_on_list?`
|
| 46 |
<p class="card-pub-isbn">
|
|
|
|
| 48 |
${o.isbn13?`<span class="card-pub-isbn-item isbn" title="ISBN-13: ${esc(o.isbn13)}">${esc(o.isbn13)}</span>`:o.isbn10?`<span class="card-pub-isbn-item isbn" title="ISBN-10: ${esc(o.isbn10)}">${esc(o.isbn10)}</span>`:""}
|
| 49 |
${o.weeks_on_list?`<span class="card-pub-isbn-item weeks" title="${esc(t("weeks_on_list",r))}">${esc(t("card_weeks_suffix",r,{n:o.weeks_on_list}))}</span>`:""}
|
| 50 |
</p>`:""}
|
| 51 |
+
${k?`<p class="card-desc">${esc(k)}</p>`:""}
|
| 52 |
</div>
|
| 53 |
</a>
|
| 54 |
</article>
|
| 55 |
+
`}).join(""));const g=document.querySelector(".export-actions-bar");if(g){const o=g.querySelector(".export-info");if(o){const v=t("books_count",r,{count:e.length});o.innerHTML=v.replace(/(\d+)/,"<strong>$1</strong>")}}}window.addEventListener("popstate",function(e){e.state&&e.state.category&&changeCategory(e.state.category)}),document.addEventListener("DOMContentLoaded",function(){const e=document.getElementById("search-input"),n=document.getElementById("search-clear-btn");e&&(e.addEventListener("input",function(){n&&(n.style.display=this.value?"flex":"none");const a=document.getElementById("search-suggestions");a&&(a.style.display="none")}),n&&n.addEventListener("click",function(){e.value="",n.style.display="none",e.focus(),renderSearchSuggestions()}),e.addEventListener("focus",function(){setTimeout(()=>renderSearchSuggestions(),100)}),e.addEventListener("keydown",function(a){a.key==="Enter"&&(a.preventDefault(),this.value.trim()&&(saveSearchHistory(this.value.trim()),applyFilters()))})),document.addEventListener("click",function(a){const s=document.getElementById("search-suggestions"),i=document.getElementById("search-input");s&&i&&!a.target.closest(".search-box")&&(s.style.display="none")}),initOnDemandTranslation()});function refreshData(){showLoading("\u5237\u65B0\u4E2D..."),window.location.href=window.location.pathname+"?refresh=1"}function exportBooks(e){showToast("\u6B63\u5728\u5BFC\u51FA...","info"),window.location.href=`/api/export/${encodeURIComponent(e)}`}const booksGrid=document.getElementById("books-grid");function handleCardClick(e){const n=e.target.closest(".btn-favorite");if(n){e.stopPropagation();const l=n.getAttribute("data-isbn");typeof toggleFavorite=="function"&&toggleFavorite(n,l);return}const a=e.target.closest(".btn-share");if(a){e.stopPropagation();const l=a.getAttribute("data-title"),r=a.getAttribute("data-author");typeof shareBook=="function"&&shareBook(l,r);return}if(e.target.closest("a[href]"))return;const s=e.target.closest(".card[data-index], .list-item[data-index]");if(!s)return;const i=s.getAttribute("data-index"),c=s.getAttribute("data-category")||window.currentCategory||window.APP_CONFIG.currentCategory;window.location.href=`/book/${encodeURIComponent(i)}?category=${encodeURIComponent(c)}`}booksGrid&&booksGrid.addEventListener("click",handleCardClick);function handleCardKeydown(e){if(!e.target.closest("a[href]")&&(e.key==="Enter"||e.key===" ")){const n=e.target.closest(".card[data-index], .list-item[data-index]");n&&(e.preventDefault(),n.click())}}booksGrid&&booksGrid.addEventListener("keydown",handleCardKeydown);const categorySelect=document.getElementById("category-select");categorySelect&&categorySelect.addEventListener("change",function(){changeCategory(this.value)});const btnSearch=document.getElementById("btn-search"),btnClear=document.getElementById("btn-clear"),btnExportAll=document.getElementById("btn-export-all"),refreshDataLink=document.getElementById("refresh-data-link");btnSearch&&btnSearch.addEventListener("click",()=>{typeof applyFilters=="function"&&applyFilters()}),btnClear&&btnClear.addEventListener("click",()=>{typeof clearFilters=="function"&&clearFilters()}),btnExportAll&&btnExportAll.addEventListener("click",()=>{typeof exportBooks=="function"&&exportBooks("all")}),refreshDataLink&&refreshDataLink.addEventListener("click",()=>{typeof refreshData=="function"&&refreshData()});const searchSuggestions=document.getElementById("search-suggestions");searchSuggestions&&searchSuggestions.addEventListener("click",function(e){const n=e.target.closest(".delete-history");if(n){e.stopPropagation();const s=n.getAttribute("data-delete-query");typeof deleteHistoryItem=="function"&&deleteHistoryItem(s);return}const a=e.target.closest(".suggestion-item[data-search-query]");if(a){const s=a.getAttribute("data-search-query");typeof applySearch=="function"&&applySearch(s)}}),window.addEventListener("languagechange",function(e){var n=e.detail.language;if(currentLanguage=n,typeof applyPageTranslation=="function"&&applyPageTranslation(n),typeof updateCategorySelectOptions=="function")try{updateCategorySelectOptions(n)}catch(a){console.warn("updateCategorySelectOptions:",a)}if(typeof rerenderCurrentBooks=="function")try{rerenderCurrentBooks(n)}catch(a){console.warn("rerenderCurrentBooks:",a)}if(typeof BookI18n<"u"&&BookI18n.size()>0)try{BookI18n.applyLanguage(n)}catch(a){console.warn("BookI18n error:",a)}});function initOnDemandTranslation(){try{let g=function(){i&&(i.textContent="\u6B63\u5728\u7FFB\u8BD1... ("+r+"/"+l+")"),c&&(c.style.width=Math.round(r/l*100)+"%"),r>=l&&s&&(s.style.display="none")},o=function(){if(f||!a.length){g();return}var u=a.shift(),h=(u.getAttribute("data-isbn")||"").replace(/[^0-9Xx]/g,"");if(!h){r+=1,g(),o();return}fetch("/api/translate/book/"+encodeURIComponent(h),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({})}).then(function(d){if(!d.ok)throw(d.status===401||d.status===500||d.status===429)&&(f=!0),new Error("http "+d.status);return d.json()}).then(function(d){var y=d&&d.data&&d.data.book;y&&v(u,y),u.removeAttribute("data-needs-translation"),r+=1,g(),o()}).catch(function(){r+=1,g(),o()})},v=function(u,h){var d=h.title_zh;if(d){var y=u.querySelector("h3.list-item-title a");if(y)y.textContent=d;else{var _=u.querySelector("h3.card-title");_&&(_.textContent=d,_.setAttribute("title",d))}}var p=h.description_zh;if(p){var k=u.querySelector("p.card-desc, p.list-item-desc");k&&(k.textContent=p)}try{if(typeof BookI18n<"u"&&BookI18n.updateBatch){var b=(u.getAttribute("data-isbn")||"").replace(/[^0-9Xx]/g,"");BookI18n.updateBatch([{isbn:b,language:"zh",data:{title:d,description:p}}])}}catch{}};var m=g,w=o,I=v,e=document.documentElement.getAttribute("lang")||"",n=null;try{n=localStorage.getItem("app_language")||localStorage.getItem("bookrank_language")}catch{}if(n){if(n!=="zh")return}else if(e&&e.toLowerCase().indexOf("zh")!==0)return;var a=Array.prototype.slice.call(document.querySelectorAll('article[data-needs-translation="1"][data-isbn]')).slice(0,15);if(!a.length){hideTranslationProgress();return}var s=document.getElementById("translation-progress"),i=s?s.querySelector(".progress-text"):null,c=s?s.querySelector(".progress-fill"):null,l=a.length,r=0,f=!1;g(),setTimeout(o,1500)}catch{}}function hideTranslationProgress(){var e=document.getElementById("translation-progress");e&&(e.style.display="none")}
|
static/dist/index.min.js
CHANGED
|
@@ -12,19 +12,19 @@ let booksData=[],currentCategory="";(function(){var n=document.getElementById("i
|
|
| 12 |
<svg class="icon" width="16" height="16"><use href="#icon-clock"/></svg>
|
| 13 |
<span>${esc(c.query)}</span>
|
| 14 |
<svg class="icon delete-history" width="14" height="14" data-delete-query="${esc(c.query)}"><use href="#icon-x"/></svg>
|
| 15 |
-
</li>`}),i+="</ul>",e.innerHTML=i,e.style.display="block"}else e.style.display="none"}function deleteHistoryItem(e){try{let n=JSON.parse(localStorage.getItem("bookrank_search_history")||"[]");n=n.filter(a=>a.query!==e),localStorage.setItem("bookrank_search_history",JSON.stringify(n)),renderSearchSuggestions()}catch(n){console.error("\u5220\u9664\u641C\u7D22\u5386\u53F2\u5931\u8D25:",n)}}function applySearch(e){const n=document.getElementById("search-input");n&&(n.value=e);const a=document.getElementById("search-suggestions");a&&(a.style.display="none"),saveSearchHistory(e),applyFilters()}function toggleFavorite(e,n){if(!n)return;let a=JSON.parse(localStorage.getItem("bookrank_favorites")||"[]");const s=a.indexOf(n);s>-1?(a.splice(s,1),e.classList.remove("active"),e.setAttribute("aria-pressed","false"),showToast("\u5DF2\u53D6\u6D88\u6536\u85CF","info")):(a.push(n),e.classList.add("active"),e.setAttribute("aria-pressed","true"),showToast("\u5DF2\u6DFB\u52A0\u5230\u6536\u85CF","success")),localStorage.setItem("bookrank_favorites",JSON.stringify(a))}function shareBook(e,n){if(navigator.share)navigator.share({title:`${e} - BookRank`,text:`\u6211\u5728 BookRank \u53D1\u73B0\u4E86\u597D\u4E66: ${e} (${n})`,url:window.location.href}).catch(()=>{});else{const a=`${e} - ${n}`;navigator.clipboard.writeText(a).then(()=>{showToast("\u5DF2\u590D\u5236\u5230\u526A\u8D34\u677F","success")}).catch(()=>{showToast("\u590D\u5236\u5931\u8D25","error")})}}function getCategoryLabel(e,n){return typeof window<"u"&&window.CATEGORIES&&window.CATEGORIES.getLabel?window.CATEGORIES.getLabel(e,n):e}function buildSkeletonCardsHTML(e){for(var n=e||8,a="",s=0;s<n;s++)a+='<article class="card card-skeleton" aria-hidden="true"> <div class="skeleton skeleton-image"></div> <div class="skeleton-content"> <div class="skeleton skeleton-title"></div> <div class="skeleton skeleton-author"></div> <div class="skeleton skeleton-tag"></div> </div></article>';return a}function showSkeleton(){var e=document.getElementById("books-grid");e&&(e.innerHTML=buildSkeletonCardsHTML(8))}function hideSkeleton(){var e=document.querySelectorAll(".card-skeleton");e.forEach(function(n){n.parentNode&&n.parentNode.removeChild(n)})}function showLoading(e){const n=document.getElementById("loading-overlay"),a=document.getElementById("loading-text");n&&(n.style.display="flex"),a&&e&&(a.textContent=e)}function hideLoading(){const e=document.getElementById("loading-overlay");e&&(e.style.display="none")}document.addEventListener("DOMContentLoaded",function(){updateLanguageButtons(currentLanguage),currentLanguage==="zh"&&typeof BookI18n<"u"&&BookI18n.applyLanguage("zh")});const _memoryCategoryCache=new Map,categoryCache={get:function(e){if(_memoryCategoryCache.has(e))return _memoryCategoryCache.get(e);try{const n=`bookrank_category_${e}`,a=localStorage.getItem(n);if(a){const s=JSON.parse(a),i=["updateTime","updateFrequency","listPublishedDate"].every(c=>Object.prototype.hasOwnProperty.call(s,c));if(Date.now()-s.timestamp<864e5&&Array.isArray(s.books)&&i)return _memoryCategoryCache.set(e,s),s;localStorage.removeItem(n)}}catch{}return null},set:function(e,n,a,s,i){const c={timestamp:Date.now(),books:n,updateTime:a,updateFrequency:s,listPublishedDate:i};_memoryCategoryCache.set(e,c);try{const l=`bookrank_category_${e}`;localStorage.setItem(l,JSON.stringify(c))}catch{}}};async function changeCategory(e){if(e===window.currentCategory)return;const n=categoryCache.get(e);if(n&&Array.isArray(n.books)&&n.books.length>0){const a=n.books;window.currentCategory=e,window.booksData=a,currentCategory=e,booksData=a,typeof BookI18n<"u"&&(BookI18n.clear(),BookI18n.registerAll(a)),updateBooksOnPage(a,e,n.updateTime,n.updateFrequency,n.listPublishedDate);const s=new URLSearchParams;s.set("category",e);const i=window.location.pathname+"?"+s.toString();window.history.pushState({category:e},"",i),currentLanguage==="zh"&&typeof BookI18n<"u"&&BookI18n.applyLanguage("zh");return}showSkeleton(),showLoading("\u52A0\u8F7D\u4E2D...");try{const a=await fetch(`/api/category-books?category=${encodeURIComponent(e)}`,{headers:{"X-Requested-With":"XMLHttpRequest"}});if(!a.ok)throw new Error("\u7F51\u7EDC\u8BF7\u6C42\u5931\u8D25");const s=await a.json();if(!s.success)throw new Error(s.message||s.error||"\u52A0\u8F7D\u5931\u8D25");const i=s.data||s,c=i.books||[];categoryCache.set(e,c,i.update_time,i.update_frequency,i.list_published_date),window.currentCategory=e,window.booksData=c,currentCategory=e,booksData=c,typeof BookI18n<"u"&&(BookI18n.clear(),BookI18n.registerAll(c)),updateBooksOnPage(c,e,i.update_time,i.update_frequency,i.list_published_date);const l=new URLSearchParams;l.set("category",e);const r=window.location.pathname+"?"+l.toString();window.history.pushState({category:e},"",r),hideLoading(),currentLanguage==="zh"&&typeof BookI18n<"u"&&BookI18n.applyLanguage("zh")}catch(a){console.error("\u5206\u7C7B\u5207\u6362\u5931\u8D25:",a),showToast(t("toast_category_load_failed",currentLanguage),"error"),hideSkeleton(),hideLoading(),document.getElementById("category-select").value=window.currentCategory}}function resolveCategoryLabel(e,n,a){return a==="zh"?e.category_name||(typeof getCategoryLabel=="function"?getCategoryLabel(n,"zh"):null)||"\u865A\u6784\u7C7B":e.list_name||e.category_name||(typeof getCategoryLabel=="function"?getCategoryLabel(n,"en"):null)||"Fiction"}function rerenderCurrentBooks(e){var n=booksData;if(!Array.isArray(n)||n.length===0){var a=document.getElementById("initial-books-data");if(a)try{n=JSON.parse(a.textContent||"[]")}catch{n=[]}}if(!(!Array.isArray(n)||n.length===0)){var s=currentCategory||window.APP_CONFIG&&window.APP_CONFIG.currentCategory||"hardcover-fiction",i=document.querySelector(".page-subtitle time"),c=i?i.getAttribute("datetime"):null;try{updateBooksOnPage(n,s,c)}catch(l){console.error("[rerenderCurrentBooks] FAILED:",l.message)}}}function updateCategorySelectOptions(e){var n=document.getElementById("category-select");!n||typeof getCategoryLabel!="function"||Array.from(n.options).forEach(function(a){a.textContent=getCategoryLabel(a.value,e)})}function formatLocalTime(e,n){if(!e)return"";if(n==="zh")return e;var a=String(e).match(/^(\d{4})-(\d{2})-(\d{2})\s+(\d{1,2}):(\d{2})(?::(\d{2}))?$/);if(!a)return e;var s=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],i=a[1],c=s[parseInt(a[2],10)-1]||a[2],l=parseInt(a[3],10),r=parseInt(a[4],10),f=a[5],
|
| 16 |
<span class="cover-weeks-value"><strong>${a}</strong><span>${esc(c)}</span></span>
|
| 17 |
-
</span>`}function updateBooksOnPage(e,n,a,s,i){const c=currentLanguage==="zh",l=window.APP_CONFIG.defaultCover,r=currentLanguage,f=document.getElementById("category-select");f&&(f.value=n);const
|
| 18 |
<article class="card card-animate"
|
| 19 |
data-isbn="${esc(o.isbn13||o.isbn10||"")}"
|
| 20 |
-
data-index="${
|
| 21 |
data-category="${esc(d)}"
|
| 22 |
-
aria-label="${esc(
|
| 23 |
<a class="card-link" href="${y}">
|
| 24 |
<div class="card-image">
|
| 25 |
<div class="cover-frame">
|
| 26 |
-
<img src="${esc(coverToSrc(
|
| 27 |
-
alt="${esc(t("card_cover_alt",r,{title:
|
| 28 |
loading="lazy"
|
| 29 |
width="280"
|
| 30 |
height="240"
|
|
@@ -32,7 +32,7 @@ let booksData=[],currentCategory="";(function(){var n=document.getElementById("i
|
|
| 32 |
data-fallback="${l}">
|
| 33 |
${renderCoverWeeks(o,r)}
|
| 34 |
</div>
|
| 35 |
-
<span class="card-category-tag">${esc(
|
| 36 |
<span class="card-badge ${u===1?"gold":u===2?"silver":u===3?"bronze":"other"}"
|
| 37 |
aria-label="${esc(t("card_badge_aria",r,{n:u}))}">
|
| 38 |
${u}
|
|
@@ -40,7 +40,7 @@ let booksData=[],currentCategory="";(function(){var n=document.getElementById("i
|
|
| 40 |
${renderRankChange(o,u,r,"rank-change")}
|
| 41 |
</div>
|
| 42 |
<div class="card-content">
|
| 43 |
-
<h3 class="card-title" title="${esc(
|
| 44 |
<p class="card-author">${esc(o.author)}</p>
|
| 45 |
${o.publisher||o.isbn13||o.isbn10||o.weeks_on_list?`
|
| 46 |
<p class="card-pub-isbn">
|
|
@@ -48,8 +48,8 @@ let booksData=[],currentCategory="";(function(){var n=document.getElementById("i
|
|
| 48 |
${o.isbn13?`<span class="card-pub-isbn-item isbn" title="ISBN-13: ${esc(o.isbn13)}">${esc(o.isbn13)}</span>`:o.isbn10?`<span class="card-pub-isbn-item isbn" title="ISBN-10: ${esc(o.isbn10)}">${esc(o.isbn10)}</span>`:""}
|
| 49 |
${o.weeks_on_list?`<span class="card-pub-isbn-item weeks" title="${esc(t("weeks_on_list",r))}">${esc(t("card_weeks_suffix",r,{n:o.weeks_on_list}))}</span>`:""}
|
| 50 |
</p>`:""}
|
| 51 |
-
${
|
| 52 |
</div>
|
| 53 |
</a>
|
| 54 |
</article>
|
| 55 |
-
`}).join(""));const g=document.querySelector(".export-actions-bar");if(g){const o=g.querySelector(".export-info");if(o){const
|
|
|
|
| 12 |
<svg class="icon" width="16" height="16"><use href="#icon-clock"/></svg>
|
| 13 |
<span>${esc(c.query)}</span>
|
| 14 |
<svg class="icon delete-history" width="14" height="14" data-delete-query="${esc(c.query)}"><use href="#icon-x"/></svg>
|
| 15 |
+
</li>`}),i+="</ul>",e.innerHTML=i,e.style.display="block"}else e.style.display="none"}function deleteHistoryItem(e){try{let n=JSON.parse(localStorage.getItem("bookrank_search_history")||"[]");n=n.filter(a=>a.query!==e),localStorage.setItem("bookrank_search_history",JSON.stringify(n)),renderSearchSuggestions()}catch(n){console.error("\u5220\u9664\u641C\u7D22\u5386\u53F2\u5931\u8D25:",n)}}function applySearch(e){const n=document.getElementById("search-input");n&&(n.value=e);const a=document.getElementById("search-suggestions");a&&(a.style.display="none"),saveSearchHistory(e),applyFilters()}function toggleFavorite(e,n){if(!n)return;let a=JSON.parse(localStorage.getItem("bookrank_favorites")||"[]");const s=a.indexOf(n);s>-1?(a.splice(s,1),e.classList.remove("active"),e.setAttribute("aria-pressed","false"),showToast("\u5DF2\u53D6\u6D88\u6536\u85CF","info")):(a.push(n),e.classList.add("active"),e.setAttribute("aria-pressed","true"),showToast("\u5DF2\u6DFB\u52A0\u5230\u6536\u85CF","success")),localStorage.setItem("bookrank_favorites",JSON.stringify(a))}function shareBook(e,n){if(navigator.share)navigator.share({title:`${e} - BookRank`,text:`\u6211\u5728 BookRank \u53D1\u73B0\u4E86\u597D\u4E66: ${e} (${n})`,url:window.location.href}).catch(()=>{});else{const a=`${e} - ${n}`;navigator.clipboard.writeText(a).then(()=>{showToast("\u5DF2\u590D\u5236\u5230\u526A\u8D34\u677F","success")}).catch(()=>{showToast("\u590D\u5236\u5931\u8D25","error")})}}function getCategoryLabel(e,n){return typeof window<"u"&&window.CATEGORIES&&window.CATEGORIES.getLabel?window.CATEGORIES.getLabel(e,n):e}function buildSkeletonCardsHTML(e){for(var n=e||8,a="",s=0;s<n;s++)a+='<article class="card card-skeleton" aria-hidden="true"> <div class="skeleton skeleton-image"></div> <div class="skeleton-content"> <div class="skeleton skeleton-title"></div> <div class="skeleton skeleton-author"></div> <div class="skeleton skeleton-tag"></div> </div></article>';return a}function showSkeleton(){var e=document.getElementById("books-grid");e&&(e.innerHTML=buildSkeletonCardsHTML(8))}function hideSkeleton(){var e=document.querySelectorAll(".card-skeleton");e.forEach(function(n){n.parentNode&&n.parentNode.removeChild(n)})}function showLoading(e){const n=document.getElementById("loading-overlay"),a=document.getElementById("loading-text");n&&(n.style.display="flex"),a&&e&&(a.textContent=e)}function hideLoading(){const e=document.getElementById("loading-overlay");e&&(e.style.display="none")}document.addEventListener("DOMContentLoaded",function(){updateLanguageButtons(currentLanguage),currentLanguage==="zh"&&typeof BookI18n<"u"&&BookI18n.applyLanguage("zh")});const _memoryCategoryCache=new Map,categoryCache={get:function(e){if(_memoryCategoryCache.has(e))return _memoryCategoryCache.get(e);try{const n=`bookrank_category_${e}`,a=localStorage.getItem(n);if(a){const s=JSON.parse(a),i=["updateTime","updateFrequency","listPublishedDate"].every(c=>Object.prototype.hasOwnProperty.call(s,c));if(Date.now()-s.timestamp<864e5&&Array.isArray(s.books)&&i)return _memoryCategoryCache.set(e,s),s;localStorage.removeItem(n)}}catch{}return null},set:function(e,n,a,s,i){const c={timestamp:Date.now(),books:n,updateTime:a,updateFrequency:s,listPublishedDate:i};_memoryCategoryCache.set(e,c);try{const l=`bookrank_category_${e}`;localStorage.setItem(l,JSON.stringify(c))}catch{}}};async function changeCategory(e){if(e===window.currentCategory)return;const n=categoryCache.get(e);if(n&&Array.isArray(n.books)&&n.books.length>0){const a=n.books;window.currentCategory=e,window.booksData=a,currentCategory=e,booksData=a,typeof BookI18n<"u"&&(BookI18n.clear(),BookI18n.registerAll(a)),updateBooksOnPage(a,e,n.updateTime,n.updateFrequency,n.listPublishedDate);const s=new URLSearchParams;s.set("category",e);const i=window.location.pathname+"?"+s.toString();window.history.pushState({category:e},"",i),currentLanguage==="zh"&&typeof BookI18n<"u"&&BookI18n.applyLanguage("zh");return}showSkeleton(),showLoading("\u52A0\u8F7D\u4E2D...");try{const a=await fetch(`/api/category-books?category=${encodeURIComponent(e)}`,{headers:{"X-Requested-With":"XMLHttpRequest"}});if(!a.ok)throw new Error("\u7F51\u7EDC\u8BF7\u6C42\u5931\u8D25");const s=await a.json();if(!s.success)throw new Error(s.message||s.error||"\u52A0\u8F7D\u5931\u8D25");const i=s.data||s,c=i.books||[];categoryCache.set(e,c,i.update_time,i.update_frequency,i.list_published_date),window.currentCategory=e,window.booksData=c,currentCategory=e,booksData=c,typeof BookI18n<"u"&&(BookI18n.clear(),BookI18n.registerAll(c)),updateBooksOnPage(c,e,i.update_time,i.update_frequency,i.list_published_date);const l=new URLSearchParams;l.set("category",e);const r=window.location.pathname+"?"+l.toString();window.history.pushState({category:e},"",r),hideLoading(),currentLanguage==="zh"&&typeof BookI18n<"u"&&BookI18n.applyLanguage("zh")}catch(a){console.error("\u5206\u7C7B\u5207\u6362\u5931\u8D25:",a),showToast(t("toast_category_load_failed",currentLanguage),"error"),hideSkeleton(),hideLoading(),document.getElementById("category-select").value=window.currentCategory}}function resolveCategoryLabel(e,n,a){return a==="zh"?e.category_name||(typeof getCategoryLabel=="function"?getCategoryLabel(n,"zh"):null)||"\u865A\u6784\u7C7B":e.list_name||e.category_name||(typeof getCategoryLabel=="function"?getCategoryLabel(n,"en"):null)||"Fiction"}function rerenderCurrentBooks(e){var n=booksData;if(!Array.isArray(n)||n.length===0){var a=document.getElementById("initial-books-data");if(a)try{n=JSON.parse(a.textContent||"[]")}catch{n=[]}}if(!(!Array.isArray(n)||n.length===0)){var s=currentCategory||window.APP_CONFIG&&window.APP_CONFIG.currentCategory||"hardcover-fiction",i=document.querySelector(".page-subtitle time"),c=i?i.getAttribute("datetime"):null;try{updateBooksOnPage(n,s,c)}catch(l){console.error("[rerenderCurrentBooks] FAILED:",l.message)}}}function updateCategorySelectOptions(e){var n=document.getElementById("category-select");!n||typeof getCategoryLabel!="function"||Array.from(n.options).forEach(function(a){a.textContent=getCategoryLabel(a.value,e)})}function formatLocalTime(e,n){if(!e)return"";if(n==="zh")return e;var a=String(e).match(/^(\d{4})-(\d{2})-(\d{2})\s+(\d{1,2}):(\d{2})(?::(\d{2}))?$/);if(!a)return e;var s=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],i=a[1],c=s[parseInt(a[2],10)-1]||a[2],l=parseInt(a[3],10),r=parseInt(a[4],10),f=a[5],m=r>=12?"PM":"AM",w=r%12||12;return c+" "+l+", "+i+" "+w+":"+f+" "+m}function getCategoryUpdateFrequency(e,n){return n?String(n).toLowerCase():(window.APP_CONFIG&&Array.isArray(window.APP_CONFIG.monthlyCategories)?window.APP_CONFIG.monthlyCategories:[]).includes(e)?"monthly":"weekly"}function getListPublishedDate(e,n){if(n)return n;if(!Array.isArray(e))return"";const a=e.find(s=>s&&s.published_date&&s.published_date!=="Unknown");return a?a.published_date:""}function updateMonthlyListHint(e,n,a,s,i){const c=document.getElementById("monthly-list-hint");if(!c)return;if(getCategoryUpdateFrequency(e,a)!=="monthly"){c.hidden=!0,c.textContent="";return}const r=getListPublishedDate(n,s);c.textContent=r?t("monthly_list_with_date",i,{date:r}):t("monthly_list",i),c.hidden=!1}function renderRankChange(e,n,a,s){const i=Number(e.previous_rank??e.rank_last_week??0);if(i>0){const l=i-n;if(!l)return"";const r=l>0?"up":"down",f=t(l>0?"card_rank_up_aria":"card_rank_down_aria",a,{n:Math.abs(l)});return`<span class="${s} ${r}" aria-label="${esc(f)}">${l>0?"+":""}${l}</span>`}const c=Number(e.weeks_on_list)||0;return e.is_new??(i===0&&c===1)?`<span class="${s} new" aria-label="${esc(t("card_new_aria",a))}">${esc(t("card_new_badge",a))}</span>`:e.is_returning??(i===0&&c>1)?`<span class="${s} new" aria-label="${a==="zh"?"\u91CD\u8FD4\u699C\u5355":"Returning to the list"}">${a==="zh"?"\u91CD\u8FD4":"RETURN"}</span>`:""}function renderCoverWeeks(e,n){const a=Number(e.weeks_on_list)||0;if(a<=0)return"";const s=t("weeks_on_list",n),c=t("card_weeks_suffix",n,{n:a}).replace(String(a),"").trim();return`<span class="cover-weeks" role="img" aria-label="${esc(s)}: ${a}${esc(c)}">
|
| 16 |
<span class="cover-weeks-value"><strong>${a}</strong><span>${esc(c)}</span></span>
|
| 17 |
+
</span>`}function updateBooksOnPage(e,n,a,s,i){const c=currentLanguage==="zh",l=window.APP_CONFIG.defaultCover,r=currentLanguage,f=document.getElementById("category-select");f&&(f.value=n);const m=document.querySelector(".page-subtitle time");if(m){m.setAttribute("datetime",a||"");var w=formatLocalTime(a,r);m.textContent=w?t("time_updated_at",r,{time:w}):t("time_just_now",r)}updateMonthlyListHint(n,e,s,i,r);const I=document.getElementById("books-grid");I&&(I.innerHTML=e.map((o,v)=>{const u=Number(o.rank)||v+1,h=o.source_index??u-1,d=o.source_category||n,y=`/book/${encodeURIComponent(h)}?category=${encodeURIComponent(d)}`,_=o.cover&&o.cover!==l?o.cover:o._original_cover||l,p=c&&o.title_zh||o.title,k=c?o.description_zh||o.description||"":o.description||"",b=resolveCategoryLabel(o,n,r),C=coverToSrc(o._original_cover);return`
|
| 18 |
<article class="card card-animate"
|
| 19 |
data-isbn="${esc(o.isbn13||o.isbn10||"")}"
|
| 20 |
+
data-index="${h}"
|
| 21 |
data-category="${esc(d)}"
|
| 22 |
+
aria-label="${esc(p)} - ${esc(t("card_rank_aria",r,{n:u}))}">
|
| 23 |
<a class="card-link" href="${y}">
|
| 24 |
<div class="card-image">
|
| 25 |
<div class="cover-frame">
|
| 26 |
+
<img src="${esc(coverToSrc(_)||l)}"
|
| 27 |
+
alt="${esc(t("card_cover_alt",r,{title:p}))}"
|
| 28 |
loading="lazy"
|
| 29 |
width="280"
|
| 30 |
height="240"
|
|
|
|
| 32 |
data-fallback="${l}">
|
| 33 |
${renderCoverWeeks(o,r)}
|
| 34 |
</div>
|
| 35 |
+
<span class="card-category-tag">${esc(b)}</span>
|
| 36 |
<span class="card-badge ${u===1?"gold":u===2?"silver":u===3?"bronze":"other"}"
|
| 37 |
aria-label="${esc(t("card_badge_aria",r,{n:u}))}">
|
| 38 |
${u}
|
|
|
|
| 40 |
${renderRankChange(o,u,r,"rank-change")}
|
| 41 |
</div>
|
| 42 |
<div class="card-content">
|
| 43 |
+
<h3 class="card-title" title="${esc(p)}">${esc(p)}</h3>
|
| 44 |
<p class="card-author">${esc(o.author)}</p>
|
| 45 |
${o.publisher||o.isbn13||o.isbn10||o.weeks_on_list?`
|
| 46 |
<p class="card-pub-isbn">
|
|
|
|
| 48 |
${o.isbn13?`<span class="card-pub-isbn-item isbn" title="ISBN-13: ${esc(o.isbn13)}">${esc(o.isbn13)}</span>`:o.isbn10?`<span class="card-pub-isbn-item isbn" title="ISBN-10: ${esc(o.isbn10)}">${esc(o.isbn10)}</span>`:""}
|
| 49 |
${o.weeks_on_list?`<span class="card-pub-isbn-item weeks" title="${esc(t("weeks_on_list",r))}">${esc(t("card_weeks_suffix",r,{n:o.weeks_on_list}))}</span>`:""}
|
| 50 |
</p>`:""}
|
| 51 |
+
${k?`<p class="card-desc">${esc(k)}</p>`:""}
|
| 52 |
</div>
|
| 53 |
</a>
|
| 54 |
</article>
|
| 55 |
+
`}).join(""));const g=document.querySelector(".export-actions-bar");if(g){const o=g.querySelector(".export-info");if(o){const v=t("books_count",r,{count:e.length});o.innerHTML=v.replace(/(\d+)/,"<strong>$1</strong>")}}}window.addEventListener("popstate",function(e){e.state&&e.state.category&&changeCategory(e.state.category)}),document.addEventListener("DOMContentLoaded",function(){const e=document.getElementById("search-input"),n=document.getElementById("search-clear-btn");e&&(e.addEventListener("input",function(){n&&(n.style.display=this.value?"flex":"none");const a=document.getElementById("search-suggestions");a&&(a.style.display="none")}),n&&n.addEventListener("click",function(){e.value="",n.style.display="none",e.focus(),renderSearchSuggestions()}),e.addEventListener("focus",function(){setTimeout(()=>renderSearchSuggestions(),100)}),e.addEventListener("keydown",function(a){a.key==="Enter"&&(a.preventDefault(),this.value.trim()&&(saveSearchHistory(this.value.trim()),applyFilters()))})),document.addEventListener("click",function(a){const s=document.getElementById("search-suggestions"),i=document.getElementById("search-input");s&&i&&!a.target.closest(".search-box")&&(s.style.display="none")}),initOnDemandTranslation()});function refreshData(){showLoading("\u5237\u65B0\u4E2D..."),window.location.href=window.location.pathname+"?refresh=1"}function exportBooks(e){showToast("\u6B63\u5728\u5BFC\u51FA...","info"),window.location.href=`/api/export/${encodeURIComponent(e)}`}const booksGrid=document.getElementById("books-grid");function handleCardClick(e){const n=e.target.closest(".btn-favorite");if(n){e.stopPropagation();const l=n.getAttribute("data-isbn");typeof toggleFavorite=="function"&&toggleFavorite(n,l);return}const a=e.target.closest(".btn-share");if(a){e.stopPropagation();const l=a.getAttribute("data-title"),r=a.getAttribute("data-author");typeof shareBook=="function"&&shareBook(l,r);return}if(e.target.closest("a[href]"))return;const s=e.target.closest(".card[data-index], .list-item[data-index]");if(!s)return;const i=s.getAttribute("data-index"),c=s.getAttribute("data-category")||window.currentCategory||window.APP_CONFIG.currentCategory;window.location.href=`/book/${encodeURIComponent(i)}?category=${encodeURIComponent(c)}`}booksGrid&&booksGrid.addEventListener("click",handleCardClick);function handleCardKeydown(e){if(!e.target.closest("a[href]")&&(e.key==="Enter"||e.key===" ")){const n=e.target.closest(".card[data-index], .list-item[data-index]");n&&(e.preventDefault(),n.click())}}booksGrid&&booksGrid.addEventListener("keydown",handleCardKeydown);const categorySelect=document.getElementById("category-select");categorySelect&&categorySelect.addEventListener("change",function(){changeCategory(this.value)});const btnSearch=document.getElementById("btn-search"),btnClear=document.getElementById("btn-clear"),btnExportAll=document.getElementById("btn-export-all"),refreshDataLink=document.getElementById("refresh-data-link");btnSearch&&btnSearch.addEventListener("click",()=>{typeof applyFilters=="function"&&applyFilters()}),btnClear&&btnClear.addEventListener("click",()=>{typeof clearFilters=="function"&&clearFilters()}),btnExportAll&&btnExportAll.addEventListener("click",()=>{typeof exportBooks=="function"&&exportBooks("all")}),refreshDataLink&&refreshDataLink.addEventListener("click",()=>{typeof refreshData=="function"&&refreshData()});const searchSuggestions=document.getElementById("search-suggestions");searchSuggestions&&searchSuggestions.addEventListener("click",function(e){const n=e.target.closest(".delete-history");if(n){e.stopPropagation();const s=n.getAttribute("data-delete-query");typeof deleteHistoryItem=="function"&&deleteHistoryItem(s);return}const a=e.target.closest(".suggestion-item[data-search-query]");if(a){const s=a.getAttribute("data-search-query");typeof applySearch=="function"&&applySearch(s)}}),window.addEventListener("languagechange",function(e){var n=e.detail.language;if(currentLanguage=n,typeof applyPageTranslation=="function"&&applyPageTranslation(n),typeof updateCategorySelectOptions=="function")try{updateCategorySelectOptions(n)}catch(a){console.warn("updateCategorySelectOptions:",a)}if(typeof rerenderCurrentBooks=="function")try{rerenderCurrentBooks(n)}catch(a){console.warn("rerenderCurrentBooks:",a)}if(typeof BookI18n<"u"&&BookI18n.size()>0)try{BookI18n.applyLanguage(n)}catch(a){console.warn("BookI18n error:",a)}});function initOnDemandTranslation(){try{let g=function(){i&&(i.textContent="\u6B63\u5728\u7FFB\u8BD1... ("+r+"/"+l+")"),c&&(c.style.width=Math.round(r/l*100)+"%"),r>=l&&s&&(s.style.display="none")},o=function(){if(f||!a.length){g();return}var u=a.shift(),h=(u.getAttribute("data-isbn")||"").replace(/[^0-9Xx]/g,"");if(!h){r+=1,g(),o();return}fetch("/api/translate/book/"+encodeURIComponent(h),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({})}).then(function(d){if(!d.ok)throw(d.status===401||d.status===500||d.status===429)&&(f=!0),new Error("http "+d.status);return d.json()}).then(function(d){var y=d&&d.data&&d.data.book;y&&v(u,y),u.removeAttribute("data-needs-translation"),r+=1,g(),o()}).catch(function(){r+=1,g(),o()})},v=function(u,h){var d=h.title_zh;if(d){var y=u.querySelector("h3.list-item-title a");if(y)y.textContent=d;else{var _=u.querySelector("h3.card-title");_&&(_.textContent=d,_.setAttribute("title",d))}}var p=h.description_zh;if(p){var k=u.querySelector("p.card-desc, p.list-item-desc");k&&(k.textContent=p)}try{if(typeof BookI18n<"u"&&BookI18n.updateBatch){var b=(u.getAttribute("data-isbn")||"").replace(/[^0-9Xx]/g,"");BookI18n.updateBatch([{isbn:b,language:"zh",data:{title:d,description:p}}])}}catch{}};var m=g,w=o,I=v,e=document.documentElement.getAttribute("lang")||"",n=null;try{n=localStorage.getItem("app_language")||localStorage.getItem("bookrank_language")}catch{}if(n){if(n!=="zh")return}else if(e&&e.toLowerCase().indexOf("zh")!==0)return;var a=Array.prototype.slice.call(document.querySelectorAll('article[data-needs-translation="1"][data-isbn]')).slice(0,15);if(!a.length){hideTranslationProgress();return}var s=document.getElementById("translation-progress"),i=s?s.querySelector(".progress-text"):null,c=s?s.querySelector(".progress-fill"):null,l=a.length,r=0,f=!1;g(),setTimeout(o,1500)}catch{}}function hideTranslationProgress(){var e=document.getElementById("translation-progress");e&&(e.style.display="none")}
|
static/dist/manifest.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
| 1 |
{
|
| 2 |
-
"app.css": "app.
|
| 3 |
"categories.js": "categories.5e0edc94.min.js",
|
| 4 |
"translations.js": "translations.53106918.min.js",
|
| 5 |
-
"book-i18n.js": "book-i18n.
|
| 6 |
"cover.js": "cover.ddaba447.min.js",
|
| 7 |
"base.js": "base.4439b358.min.js",
|
| 8 |
-
"index.js": "index.
|
| 9 |
}
|
|
|
|
| 1 |
{
|
| 2 |
+
"app.css": "app.PXLGYFCP.min.css",
|
| 3 |
"categories.js": "categories.5e0edc94.min.js",
|
| 4 |
"translations.js": "translations.53106918.min.js",
|
| 5 |
+
"book-i18n.js": "book-i18n.a1de7517.min.js",
|
| 6 |
"cover.js": "cover.ddaba447.min.js",
|
| 7 |
"base.js": "base.4439b358.min.js",
|
| 8 |
+
"index.js": "index.47804282.min.js"
|
| 9 |
}
|
static/js/book-i18n.js
CHANGED
|
@@ -195,7 +195,9 @@ var BookI18n = (function() {
|
|
| 195 |
for (var c = 0; c < cards.length; c++) {
|
| 196 |
var card = cards[c];
|
| 197 |
_updateTitleInCard(card, data.title);
|
| 198 |
-
|
|
|
|
|
|
|
| 199 |
_updateElement(card.querySelector(CAT_SELECTORS), data.category);
|
| 200 |
}
|
| 201 |
});
|
|
|
|
| 195 |
for (var c = 0; c < cards.length; c++) {
|
| 196 |
var card = cards[c];
|
| 197 |
_updateTitleInCard(card, data.title);
|
| 198 |
+
// 简介不传 truncate:整段写入,行数由 CSS 钳制决定。
|
| 199 |
+
// 这里曾传 80,与 index.js 的 100/80 一起把简介砍成开头一句。
|
| 200 |
+
_updateElement(card.querySelector(DESC_SELECTORS), data.description);
|
| 201 |
_updateElement(card.querySelector(CAT_SELECTORS), data.category);
|
| 202 |
}
|
| 203 |
});
|
static/js/index.js
CHANGED
|
@@ -649,7 +649,7 @@ function updateBooksOnPage(books, category, updateTime, updateFrequency, listPub
|
|
| 649 |
${book.isbn13 ? `<span class="card-pub-isbn-item isbn" title="ISBN-13: ${esc(book.isbn13)}">${esc(book.isbn13)}</span>` : book.isbn10 ? `<span class="card-pub-isbn-item isbn" title="ISBN-10: ${esc(book.isbn10)}">${esc(book.isbn10)}</span>` : ''}
|
| 650 |
${book.weeks_on_list ? `<span class="card-pub-isbn-item weeks" title="${esc(t('weeks_on_list', lang))}">${esc(t('card_weeks_suffix', lang, { n: book.weeks_on_list }))}</span>` : ''}
|
| 651 |
</p>` : ''}
|
| 652 |
-
${desc ? `<p class="card-desc">${esc(desc
|
| 653 |
</div>
|
| 654 |
</a>
|
| 655 |
</article>
|
|
@@ -931,8 +931,10 @@ function initOnDemandTranslation() {
|
|
| 931 |
if (desc) {
|
| 932 |
var descEl = card.querySelector('p.card-desc, p.list-item-desc');
|
| 933 |
if (descEl) {
|
| 934 |
-
|
| 935 |
-
|
|
|
|
|
|
|
| 936 |
}
|
| 937 |
}
|
| 938 |
try {
|
|
|
|
| 649 |
${book.isbn13 ? `<span class="card-pub-isbn-item isbn" title="ISBN-13: ${esc(book.isbn13)}">${esc(book.isbn13)}</span>` : book.isbn10 ? `<span class="card-pub-isbn-item isbn" title="ISBN-10: ${esc(book.isbn10)}">${esc(book.isbn10)}</span>` : ''}
|
| 650 |
${book.weeks_on_list ? `<span class="card-pub-isbn-item weeks" title="${esc(t('weeks_on_list', lang))}">${esc(t('card_weeks_suffix', lang, { n: book.weeks_on_list }))}</span>` : ''}
|
| 651 |
</p>` : ''}
|
| 652 |
+
${desc ? `<p class="card-desc">${esc(desc)}</p>` : ''}
|
| 653 |
</div>
|
| 654 |
</a>
|
| 655 |
</article>
|
|
|
|
| 931 |
if (desc) {
|
| 932 |
var descEl = card.querySelector('p.card-desc, p.list-item-desc');
|
| 933 |
if (descEl) {
|
| 934 |
+
// 简介一律整段写入:显示多少行由 CSS 决定(紧凑五列钳 5 行、
|
| 935 |
+
// 精选三列完整展示)。前端再按字数截断会与 CSS 钳制叠加,
|
| 936 |
+
// 长简介只剩开头一句 —— 服务端与 CSS 修好后仍从这里复现。
|
| 937 |
+
descEl.textContent = desc;
|
| 938 |
}
|
| 939 |
}
|
| 940 |
try {
|