h5 head 检查

This commit is contained in:
make
2025-04-06 18:10:04 +08:00
parent 7b1dc9533c
commit 3a2cdb8bf4
36 changed files with 548 additions and 294 deletions

View File

@@ -149,15 +149,16 @@ function addBookshelfFun(NovelInfo) {
}
// 删除历史记录
// 删除书架
function delBookshelfFun(intNId) {
// 获取书架数据
const arrHistory = JSON.parse(localStorage.getItem('strBookshelfKey')) || [];
console.log(arrHistory)
// 检查 arrHistory 是否为数组且不为空
if (Array.isArray(arrHistory) && arrHistory.length > 0) {
// 找到匹配 intNId 的索引
const index = arrHistory.findIndex(item => item.n_id === intNId);
const index = arrHistory.findIndex(item => item.n_id == intNId);
// 如果找到匹配项index !== -1则删除
if (index !== -1) {
@@ -188,36 +189,40 @@ function displayBookshelf() {
// 渲染书籍列表
const DomBookshelfContainer = document.getElementById('bookshelfMod-head');
const DomBookshelfContainerH5 = document.getElementById('list');
arrBookshelf.forEach(book => {
const bookElement = document.createElement('tr');
bookElement.classList.add('book-shelf'); // 添加类名
if (isMobile()) {
const bookElement = document.createElement('li');
bookElement.classList.add('book-shelf'); // 添加类名
bookElement.classList.add('li2'); // 添加类名
bookElement.innerHTML = `
<td>
<a href="/xiaoshuo/${book.og_novel_pin_yin}-${book.n_id}" >
<img class="lazyload-img"
src="/static/img/default.jpg" data-src="${book.n_cover_path}">
</a>
</td>
<td class="t2">
<a href="/xiaoshuo/${book.og_novel_pin_yin}-${book.n_id}" >${book.og_novel_book_name}</a>
</td>
<td class="t3">
<a href="/xiaoshuo/${book.og_novel_pin_yin}-${book.n_id}/zhang-${book.c_sort_num}" >${book.c_name}</a>
</td>
<td class="t4">
<a href="/xiaoshuo/${book.og_novel_pin_yin}-${book.n_id}" >${book.og_novel_author}</a>
</td>
<td class="t5">3天前</td>
<td class="t6">${book.og_novel_status}</td>
<td class="t7">
<a href="/xiaoshuo/${book.og_novel_pin_yin}-${book.n_id}/zhang-${book.c_sort_num}" class="goon" >阅读</a>
<i><span class="Collection" ajax-get="" onclick="delBookshelfFun(${book.n_id})">删除</span></i>
</td>
<a href='/xiaoshuo/${book.og_novel_pin_yin}-${book.n_id}'>
<div class="leftImage2 ">
<img class="lazyload-img" src="${book.n_cover_path}" >
</div>
<div class="rightBlock">
<span class="rightBlock_title">${book.og_novel_book_name}</span>
<span class="rightBlock_name">${book.og_novel_author}</span>
<span class="rightBlock_con rightBlock_con2">
<span class="con">
<span class="spanLi">${book.c_name}</span>
</span>
<span class="spanLi Time">${book.og_novel_update_time ?? ''}</span>
<span class="rightJustTime"
onclick="javascript:window.location.href='/xiaoshuo/${book.og_novel_pin_yin}-${book.n_id}/zhang-${book.c_sort_num}';return false;">
继续阅读
</span>
</span>
</div>
</a>
<span class="deleteBlock" onclick="delBookshelfFun(${book.n_id})"></span>
`;
DomBookshelfContainerH5.appendChild(bookElement);
} else {
const bookElement = document.createElement('tr');
bookElement.classList.add('book-shelf'); // 添加类名
bookElement.innerHTML = `
<td>
<a href="/pc/xiaoshuo/${book.og_novel_pin_yin}-${book.n_id}" >
@@ -242,8 +247,9 @@ function displayBookshelf() {
</td>
`;
DomBookshelfContainer.after(bookElement);
}
DomBookshelfContainer.after(bookElement);
});
}
@@ -258,7 +264,7 @@ function addHistoryFun(NovelInfo) {
// 获取本地存储中的历史记录
let arrBookshelf = JSON.parse(localStorage.getItem('strHistoryKey')) || [];
// 检查书籍是否已存在
const index = arrBookshelf.findIndex(item => item.n_id === NovelInfo.n_id);
const index = arrBookshelf.findIndex(item => item.n_id == NovelInfo.n_id);
if (index !== -1) {
// 如果存在,更新该书籍的信息
@@ -280,7 +286,7 @@ function delHistoryFun(intNId) {
// 检查 arrHistory 是否为数组且不为空
if (Array.isArray(arrHistory) && arrHistory.length > 0) {
// 找到匹配 intNId 的索引
const index = arrHistory.findIndex(item => item.n_id === intNId);
const index = arrHistory.findIndex(item => item.n_id == intNId);
// 如果找到匹配项index !== -1则删除
if (index !== -1) {
@@ -311,36 +317,36 @@ function displayHistory() {
// 渲染书籍列表
const DomHistoryContainer = document.getElementById('bookshelfMod-head');
const DomBookshelfContainerH5 = document.getElementById('list');
arrHistory.forEach(book => {
const bookElement = document.createElement('tr');
bookElement.classList.add('book-history'); // 添加类名
if (isMobile()) {
const bookElement = document.createElement('li');
bookElement.classList.add('book-history'); // 添加类名
bookElement.classList.add('li2'); // 添加类名
bookElement.innerHTML = `
<td>
<a href="/xiaoshuo/${book.og_novel_pin_yin}-${book.n_id}" >
<img class="lazyload-img"
src="/static/img/default.jpg" data-src="${book.n_cover_path}">
</a>
</td>
<td class="t2">
<a href="/xiaoshuo/${book.og_novel_pin_yin}-${book.n_id}" >${book.og_novel_book_name}</a>
</td>
<td class="t3">
<a href="/xiaoshuo/${book.og_novel_pin_yin}-${book.n_id}/zhang-${book.c_sort_num}" >${book.c_name}</a>
</td>
<td class="t4">
<a href="/xiaoshuo/${book.og_novel_pin_yin}-${book.n_id}" >${book.og_novel_author}</a>
</td>
<td class="t5">3天前</td>
<td class="t6">${book.og_novel_status}</td>
<td class="t7">
<a href="/xiaoshuo/${book.og_novel_pin_yin}-${book.n_id}/zhang-${book.c_sort_num}" class="goon" >阅读</a>
<i><span class="Collection" ajax-get="" onclick="delHistoryFun(${book.n_id})">删除</span></i>
</td>
<a href='/xiaoshuo/${book.og_novel_pin_yin}-${book.n_id}'>
<div class="leftImage2 ">
<img class="lazyload-img" src="${book.n_cover_path}" >
</div>
<div class="rightBlock">
<span class="rightBlock_title">${book.og_novel_book_name}</span>
<span class="rightBlock_name">${book.og_novel_author}</span>
<span class="rightBlock_con rightBlock_con2">
<span class="con">
<span class="spanLi">${book.c_name}</span>
</span>
<span class="spanLi Time">${book.og_novel_update_time ?? ''}</span>
<span class="rightJustTime"
onclick="javascript:window.location.href='/xiaoshuo/${book.og_novel_pin_yin}-${book.n_id}/zhang-${book.c_sort_num}';return false;">继续阅读</span>
</span>
</div>
</a>
<span class="deleteBlock" onclick="delHistoryFun(${book.n_id})"></span>
`;
DomBookshelfContainerH5.appendChild(bookElement);
} else {
const bookElement = document.createElement('tr');
bookElement.classList.add('book-history'); // 添加类名
bookElement.innerHTML = `
<td>
<a href="/pc/xiaoshuo/${book.og_novel_pin_yin}-${book.n_id}" >
@@ -356,7 +362,7 @@ function displayHistory() {
<td class="t4">
<a href="/pc/xiaoshuo/${book.og_novel_pin_yin}-${book.n_id}" >${book.og_novel_author}</a>
</td>
<td class="t5">${book.og_novel_update_time}</td>
<td class="t5">${book.og_novel_update_time ?? ''}</td>
<td class="t6">${book.og_novel_status}</td>
<td class="t7">
@@ -365,8 +371,9 @@ function displayHistory() {
</td>
`;
DomHistoryContainer.after(bookElement);
}
DomHistoryContainer.after(bookElement);
});
}