✨ feat(bookSource): 光遇式聚合书源适配阅读 app 并完善评论体验
- 聚合书源取代早期书源版本:发现页筛选宫格/分类宫格、x:t:m:d: 前缀搜索、 fqtab 类型随书切换、段评气泡(光遇 svgs 六样式);showCmt 能力检测,魔改版 原地弹窗(点遮罩关闭)、官方阅读降级 startBrowser;jsLib 不引用规则变量, searchUrl 修正编码与作用域 - 评论页:注入绝对 API_BASE,修复弹窗 WebView 内切换排序/懒加载失败; externalBaseURL 识别 X-Forwarded-Proto,气泡 ident 不再硬编码 http; 顶栏固定(拖拽把手)+评论区独立滚动 - 部署:证书方案从 certbot 迁移到 acme.sh(CERT_DIR 可配置) - 忽略 .codegraph 本地索引目录
This commit is contained in:
1 parent
a652049ba4
commit
60f55a9de8
7 files changed
+208
-125
No files matched your search
@@ -49,25 +49,50 @@
|
||||
box-sizing: border-box;
|
||||
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
|
||||
}
|
||||
html, body { height: 100%; }
|
||||
body {
|
||||
background-color: var(--bg-primary);
|
||||
color: var(--text-primary);
|
||||
padding: 15px;
|
||||
max-width: 600px;
|
||||
margin: 0 auto;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
overflow: hidden;
|
||||
transition: background-color 0.3s ease, color 0.3s ease;
|
||||
}
|
||||
.header {
|
||||
flex-shrink: 0;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 20px;
|
||||
padding: 10px 15px;
|
||||
padding: 10px 15px 12px;
|
||||
background: var(--bg-secondary);
|
||||
border-radius: 12px;
|
||||
border-radius: 20px 20px 0 0;
|
||||
border-bottom: 1px solid var(--border-color);
|
||||
box-shadow: 0 2px 8px var(--shadow);
|
||||
position: relative;
|
||||
z-index: 10;
|
||||
transition: background-color 0.3s ease;
|
||||
}
|
||||
/* BottomSheet 顶部拖拽把手 */
|
||||
.header::before {
|
||||
content: '';
|
||||
position: absolute;
|
||||
top: 6px;
|
||||
left: 50%;
|
||||
transform: translateX(-50%);
|
||||
width: 36px;
|
||||
height: 4px;
|
||||
border-radius: 2px;
|
||||
background: var(--border-color);
|
||||
}
|
||||
#comment-list {
|
||||
flex: 1;
|
||||
overflow-y: auto;
|
||||
-webkit-overflow-scrolling: touch;
|
||||
padding: 15px;
|
||||
overscroll-behavior: contain;
|
||||
}
|
||||
.header h1 {
|
||||
font-size: 18px;
|
||||
color: var(--text-primary);
|
||||
@@ -333,8 +358,8 @@
|
||||
<i class="fas fa-book-open" style="color: var(--text-tertiary); font-size: 16px; margin: 0 10px;"></i>
|
||||
</span>
|
||||
<div class="sort-tabs">
|
||||
<div class="sort-tab{{if eq .Sort 1}} active{{end}}" onclick="switchSort(1)">最热</div>
|
||||
<div class="sort-tab{{if eq .Sort 3}} active{{end}}" onclick="switchSort(3)">最新</div>
|
||||
<div class="sort-tab{{if eq .Sort 1}} active{{end}}" onclick="switchSort(1, this)">最热</div>
|
||||
<div class="sort-tab{{if eq .Sort 3}} active{{end}}" onclick="switchSort(3, this)">最新</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="comment-list">
|
||||
@@ -370,6 +395,8 @@
|
||||
const bookID = '{{.BookID}}';
|
||||
const para = {{.Para}};
|
||||
let currentSort = {{.Sort}};
|
||||
// 服务端注入的绝对地址:弹窗 WebView(loadDataWithBaseURL) 中相对路径解析不可靠
|
||||
const API_BASE = '{{.BaseURL}}';
|
||||
|
||||
const commentList = document.getElementById('comment-list');
|
||||
const imageViewer = document.getElementById('imageViewer');
|
||||
@@ -380,7 +407,7 @@
|
||||
// 已加载回复的评论
|
||||
const loadedReplies = new Set();
|
||||
|
||||
// URL 构建
|
||||
// URL 构建(绝对地址,兼容弹窗 WebView)
|
||||
function buildReviewURL(params) {
|
||||
const baseParams = {
|
||||
item_id: itemID,
|
||||
@@ -388,7 +415,7 @@
|
||||
para: para
|
||||
};
|
||||
const query = new URLSearchParams({...baseParams, ...params});
|
||||
return '/review?' + query.toString();
|
||||
return API_BASE + '/review?' + query.toString();
|
||||
}
|
||||
|
||||
// 时间格式化
|
||||
@@ -429,11 +456,11 @@
|
||||
};
|
||||
}
|
||||
|
||||
// 滚动信息获取
|
||||
// 滚动信息获取(评论区为独立滚动容器)
|
||||
function getScrollInfo() {
|
||||
const scrollTop = window.pageYOffset || document.documentElement.scrollTop;
|
||||
const scrollHeight = document.documentElement.scrollHeight;
|
||||
const clientHeight = document.documentElement.clientHeight;
|
||||
const scrollTop = commentList.scrollTop;
|
||||
const scrollHeight = commentList.scrollHeight;
|
||||
const clientHeight = commentList.clientHeight;
|
||||
return {
|
||||
scrollTop,
|
||||
scrollHeight,
|
||||
@@ -443,11 +470,11 @@
|
||||
}
|
||||
|
||||
// 切换排序
|
||||
async function switchSort(newSort) {
|
||||
async function switchSort(newSort, tab) {
|
||||
if (currentSort === newSort) return;
|
||||
|
||||
document.querySelectorAll('.sort-tab').forEach(tab => tab.classList.remove('active'));
|
||||
event.target.closest('.sort-tab').classList.add('active');
|
||||
|
||||
document.querySelectorAll('.sort-tab').forEach(t => t.classList.remove('active'));
|
||||
if (tab) tab.classList.add('active');
|
||||
|
||||
commentList.innerHTML = LOADING_HTML;
|
||||
|
||||
@@ -479,7 +506,7 @@
|
||||
}
|
||||
|
||||
loadedReplies.clear();
|
||||
window.scrollTo({ top: 0, behavior: 'smooth' });
|
||||
commentList.scrollTo({ top: 0, behavior: 'smooth' });
|
||||
} else {
|
||||
commentList.innerHTML = '<div class="empty">加载失败,请重试</div>';
|
||||
commentIndex = 0;
|
||||
@@ -751,25 +778,25 @@
|
||||
|
||||
// 回到顶部
|
||||
function scrollToTop() {
|
||||
window.scrollTo({
|
||||
commentList.scrollTo({
|
||||
top: 0,
|
||||
behavior: 'smooth'
|
||||
});
|
||||
}
|
||||
|
||||
// 滚动监听
|
||||
|
||||
// 滚动监听(挂在评论容器上,顶栏固定不参与滚动)
|
||||
const handleScroll = debounce(() => {
|
||||
const scroll = getScrollInfo();
|
||||
|
||||
|
||||
// 显示/隐藏回到顶部按钮
|
||||
backToTopBtn.classList.toggle('show', scroll.scrollTop > 300);
|
||||
|
||||
|
||||
// 距离底部 200px 时触发加载
|
||||
if (scroll.distanceFromBottom <= 200) {
|
||||
loadMoreComments();
|
||||
}
|
||||
}, 100);
|
||||
|
||||
window.addEventListener('scroll', handleScroll, { passive: true });
|
||||
|
||||
commentList.addEventListener('scroll', handleScroll, { passive: true });
|
||||
</script>
|
||||
</body>
|
||||
Reference in new issue
Block a user