This commit is contained in:
make
2025-04-21 11:59:52 +08:00
parent 3216cffb5e
commit adf88aef23
27 changed files with 543 additions and 329 deletions

View File

@@ -151,6 +151,7 @@ function incShouCangFun(intId) {
}
const strBookshelfKey = window.location.hostname + 'strBookshelfKey';
const strHistoryKey = window.location.hostname + 'strHistoryKey';
// 加入书架 addShuJiaFun
function addBookshelfFun(NovelInfo) {
@@ -233,13 +234,13 @@ function displayBookshelf() {
<img class="lazyload-img" src="${book.n_cover_path}" >
</div>
<div class="rightBlock">
<span class="rightBlock_title">${book.n_namen}</span>
<span class="rightBlock_title">${book.n_name}</span>
<span class="rightBlock_name">${book.n_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="spanLi Time">${book.n_update_time ?? ''}</span>
<span class="rightJustTime" onclick="javascript:window.location.href='${strNovelChapterUrl}';return false;">
继续阅读
</span>
@@ -260,7 +261,7 @@ function displayBookshelf() {
</a>
</td>
<td class="t2">
<a href="${strPcPath}${strNovelUrl}" >${book.n_namen}</a>
<a href="${strPcPath}${strNovelUrl}" >${book.n_name}</a>
</td>
<td class="t3">
<a href="${strPcPath}${strNovelChapterUrl}" >${book.c_name}</a>
@@ -268,9 +269,9 @@ function displayBookshelf() {
<td class="t4">
<a href="${strPcPath}${strSearchUrl}" >${book.n_author}</a>
</td>
<td class="t5">${book.og_novel_update_time}</td>
<td class="t5">${book.n_update_time}</td>
<td class="t6">${book.og_novel_status}</td>
<td class="t6">${book.n_status}</td>
<td class="t7">
<a href="${strPcPath}${strNovelChapterUrl}" class="goon" >阅读</a>
<i><span class="Collection" ajax-get="" onclick="delBookshelfFun(${book.n_id})">删除</span></i>
@@ -292,7 +293,7 @@ function addHistoryFun(NovelInfo) {
}
// 获取本地存储中的历史记录
let arrBookshelf = JSON.parse(localStorage.getItem('strHistoryKey')) || [];
let arrBookshelf = JSON.parse(localStorage.getItem(strHistoryKey)) || [];
// 检查书籍是否已存在
const index = arrBookshelf.findIndex(item => item.n_id == NovelInfo.n_id);
@@ -305,13 +306,13 @@ function addHistoryFun(NovelInfo) {
}
// 更新本地存储
localStorage.setItem('strHistoryKey', JSON.stringify(arrBookshelf));
localStorage.setItem(strHistoryKey, JSON.stringify(arrBookshelf));
}
// 删除历史记录
function delHistoryFun(intNId) {
// 获取书架数据
const arrHistory = JSON.parse(localStorage.getItem('strHistoryKey')) || [];
const arrHistory = JSON.parse(localStorage.getItem(strHistoryKey)) || [];
// 检查 arrHistory 是否为数组且不为空
if (Array.isArray(arrHistory) && arrHistory.length > 0) {
@@ -322,7 +323,7 @@ function delHistoryFun(intNId) {
if (index !== -1) {
arrHistory.splice(index, 1); // 删除该项
// 更新 localStorage
localStorage.setItem('strHistoryKey', JSON.stringify(arrHistory));
localStorage.setItem(strHistoryKey, JSON.stringify(arrHistory));
} else {
console.log(`未找到 ID 为 ${intNId} 的历史记录`);
}
@@ -330,7 +331,6 @@ function delHistoryFun(intNId) {
console.log('历史记录为空,无需删除');
}
removeElementsByClass('book-history')
// localStorage.setItem('strHistoryKey', JSON.stringify(arrHistory));
displayHistory()
}
@@ -338,7 +338,7 @@ function delHistoryFun(intNId) {
function displayHistory() {
// 获取书架数据
const arrHistory = JSON.parse(localStorage.getItem('strHistoryKey')) || [];
const arrHistory = JSON.parse(localStorage.getItem(strHistoryKey)) || [];
if (arrHistory.length === 0) {
console.log('书架为空');
@@ -362,13 +362,13 @@ function displayHistory() {
<img class="lazyload-img" src="${book.n_cover_path}" >
</div>
<div class="rightBlock">
<span class="rightBlock_title">${book.n_namen}</span>
<span class="rightBlock_title">${book.n_name}</span>
<span class="rightBlock_name">${book.n_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="spanLi Time">${book.n_update_time ?? ''}</span>
<span class="rightJustTime" onclick="javascript:window.location.href='${strNovelChapterUrl}';return false;"
>继续阅读</span>
</span>
@@ -395,9 +395,9 @@ function displayHistory() {
<td class="t4">
<a href="${strPcPath}${strSearchUrl}" >${book.n_author}</a>
</td>
<td class="t5">${book.og_novel_update_time ?? ''}</td>
<td class="t5">${book.n_update_time ?? ''}</td>
<td class="t6">${book.og_novel_status}</td>
<td class="t6">${book.n_status}</td>
<td class="t7">
<a href="${strNovelChapterUrl}" class="goon" >阅读</a>
<i><span class="Collection" ajax-get="" onclick="delHistoryFun(${book.n_id})">删除</span></i>