fix: Claude
This commit is contained in:
parent
a20550422f
commit
2cefd01331
@ -64,19 +64,24 @@ const App = (function() {
|
|||||||
|
|
||||||
function showPage(page) {
|
function showPage(page) {
|
||||||
// 重置UI状态
|
// 重置UI状态
|
||||||
if (page !== 'reader') {
|
if (page === 'reader') {
|
||||||
|
// 阅读器模式:隐藏所有导航
|
||||||
|
$('#app-header').addClass('header-hidden');
|
||||||
|
$('#app-nav').addClass('nav-hidden');
|
||||||
|
$('#app-content').addClass('reader-mode').removeClass('detail-mode');
|
||||||
|
$('#reader-toolbar').removeClass('hidden');
|
||||||
|
} else if (page === 'detail') {
|
||||||
|
// 详情页:隐藏底部导航(有自己的操作栏)
|
||||||
$('#app-header').removeClass('header-hidden');
|
$('#app-header').removeClass('header-hidden');
|
||||||
$('#app-content').removeClass('reader-mode');
|
$('#app-nav').addClass('nav-hidden');
|
||||||
|
$('#app-content').removeClass('reader-mode').addClass('detail-mode');
|
||||||
|
$('#reader-toolbar').addClass('hidden');
|
||||||
|
} else {
|
||||||
|
// 普通页面:显示所有导航
|
||||||
|
$('#app-header').removeClass('header-hidden');
|
||||||
|
$('#app-nav').removeClass('nav-hidden');
|
||||||
|
$('#app-content').removeClass('reader-mode').removeClass('detail-mode');
|
||||||
$('#reader-toolbar').addClass('hidden');
|
$('#reader-toolbar').addClass('hidden');
|
||||||
|
|
||||||
// 详情页隐藏底部导航(有自己的操作栏)
|
|
||||||
if (page === 'detail') {
|
|
||||||
$('#app-nav').addClass('nav-hidden');
|
|
||||||
$('#app-content').addClass('detail-mode');
|
|
||||||
} else {
|
|
||||||
$('#app-nav').removeClass('nav-hidden');
|
|
||||||
$('#app-content').removeClass('detail-mode');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 更新页面标题
|
// 更新页面标题
|
||||||
@ -129,7 +134,19 @@ const App = (function() {
|
|||||||
|
|
||||||
// 返回按钮
|
// 返回按钮
|
||||||
$('#btn-back').on('click', function() {
|
$('#btn-back').on('click', function() {
|
||||||
window.history.back();
|
// 如果有历史记录就返回,否则跳转到书架
|
||||||
|
if (window.history.length > 1) {
|
||||||
|
const currentHash = window.location.hash;
|
||||||
|
window.history.back();
|
||||||
|
// 检查是否真的返回了,如果没有就跳转到书架
|
||||||
|
setTimeout(() => {
|
||||||
|
if (window.location.hash === currentHash) {
|
||||||
|
navigate('#/shelf');
|
||||||
|
}
|
||||||
|
}, 100);
|
||||||
|
} else {
|
||||||
|
navigate('#/shelf');
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// 搜索按钮
|
// 搜索按钮
|
||||||
@ -217,18 +234,22 @@ const App = (function() {
|
|||||||
Pages.loadNovels(0, tag);
|
Pages.loadNovels(0, tag);
|
||||||
});
|
});
|
||||||
|
|
||||||
// 加载更多
|
// 加载更多(追加模式,保持当前筛选条件)
|
||||||
$(document).on('click', '.load-more-btn', function() {
|
$(document).on('click', '.load-more-btn', function() {
|
||||||
if (Pages.hasMore()) {
|
if (Pages.hasMore()) {
|
||||||
Pages.loadNovels(Pages.currentPage() + 1, null, true);
|
Pages.loadNovels(Pages.currentPage() + 1, null, true); // append=true 会使用已保存的标签
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// 小说卡片点击
|
// 小说卡片点击(包括搜索结果中的)
|
||||||
$(document).on('click', '.novel-card, .novel-grid-card, .shelf-item', function(e) {
|
$(document).on('click', '.novel-card, .novel-grid-card, .shelf-item', function(e) {
|
||||||
if ($(e.target).closest('button').length) return;
|
if ($(e.target).closest('button').length) return;
|
||||||
const novelId = $(this).data('novel-id') || $(this).closest('[data-novel-id]').data('novel-id');
|
const novelId = $(this).data('novel-id') || $(this).closest('[data-novel-id]').data('novel-id');
|
||||||
if (novelId) {
|
if (novelId) {
|
||||||
|
// 如果在搜索面板中,先关闭搜索面板
|
||||||
|
if ($('#search-panel').is(':visible')) {
|
||||||
|
hideSearch();
|
||||||
|
}
|
||||||
navigate('#/novel/' + novelId);
|
navigate('#/novel/' + novelId);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@ -187,10 +187,10 @@ const Pages = (function() {
|
|||||||
|
|
||||||
// 加载随机推荐
|
// 加载随机推荐
|
||||||
async function loadRandomNovels() {
|
async function loadRandomNovels() {
|
||||||
$('#random-novels').html(renderSkeletonScroll(5));
|
$('#random-novels').html(renderSkeletonScroll(6));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const novels = await API.getRandomNovels(8);
|
const novels = await API.getRandomNovels(12);
|
||||||
|
|
||||||
if (novels.length === 0) {
|
if (novels.length === 0) {
|
||||||
$('#random-novels').html('<p style="padding:20px;color:var(--text-muted);">暂无推荐</p>');
|
$('#random-novels').html('<p style="padding:20px;color:var(--text-muted);">暂无推荐</p>');
|
||||||
@ -245,6 +245,7 @@ const Pages = (function() {
|
|||||||
let currentPage = 0;
|
let currentPage = 0;
|
||||||
let isLoadingMore = false;
|
let isLoadingMore = false;
|
||||||
let hasMore = true;
|
let hasMore = true;
|
||||||
|
let currentTag = null; // 保存当前选择的标签
|
||||||
|
|
||||||
async function loadTags() {
|
async function loadTags() {
|
||||||
try {
|
try {
|
||||||
@ -263,15 +264,20 @@ const Pages = (function() {
|
|||||||
if (isLoadingMore) return;
|
if (isLoadingMore) return;
|
||||||
isLoadingMore = true;
|
isLoadingMore = true;
|
||||||
|
|
||||||
|
// 如果不是追加加载,保存当前标签
|
||||||
if (!append) {
|
if (!append) {
|
||||||
currentPage = 0;
|
currentPage = 0;
|
||||||
hasMore = true;
|
hasMore = true;
|
||||||
|
currentTag = tag; // 保存当前选择的标签
|
||||||
$('#novel-list').html(renderSkeletonList(5));
|
$('#novel-list').html(renderSkeletonList(5));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 追加加载时使用已保存的标签
|
||||||
|
const useTag = append ? currentTag : tag;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const params = { page, size: 20 };
|
const params = { page, size: 20 };
|
||||||
if (tag) params.tag = tag;
|
if (useTag) params.tag = useTag;
|
||||||
|
|
||||||
const data = await API.searchNovels(params);
|
const data = await API.searchNovels(params);
|
||||||
const novels = data.content || [];
|
const novels = data.content || [];
|
||||||
|
|||||||
@ -493,10 +493,7 @@ const Reader = (function() {
|
|||||||
// 保存进度
|
// 保存进度
|
||||||
saveReadingProgress();
|
saveReadingProgress();
|
||||||
|
|
||||||
// 显示导航栏
|
// 隐藏阅读器工具栏
|
||||||
$('#app-header').removeClass('header-hidden');
|
|
||||||
$('#app-nav').removeClass('nav-hidden');
|
|
||||||
$('#app-content').removeClass('reader-mode');
|
|
||||||
$('#reader-toolbar').addClass('hidden').removeClass('visible');
|
$('#reader-toolbar').addClass('hidden').removeClass('visible');
|
||||||
|
|
||||||
// 隐藏面板
|
// 隐藏面板
|
||||||
@ -510,7 +507,7 @@ const Reader = (function() {
|
|||||||
// 解绑事件
|
// 解绑事件
|
||||||
unbindEvents();
|
unbindEvents();
|
||||||
|
|
||||||
// 返回详情页
|
// 返回详情页(showPage会处理导航栏显示状态)
|
||||||
if (currentNovelId) {
|
if (currentNovelId) {
|
||||||
window.location.hash = '#/novel/' + currentNovelId;
|
window.location.hash = '#/novel/' + currentNovelId;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user