This commit is contained in:
make
2025-04-21 17:49:17 +08:00
parent 7ef217c1b9
commit 2337ab4f7d
942 changed files with 209166 additions and 0 deletions

View File

@@ -0,0 +1,65 @@
/* 面包屑容器 */
.breadcrumb {
font-family: Arial, sans-serif;
padding: 10px 15px;
background-color: #f8f9fa;
border-radius: 5px;
margin: 10px 0;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}
/* 有序列表样式 */
.breadcrumb ol {
list-style: none;
margin: 0;
padding: 0;
display: flex;
align-items: center;
flex-wrap: wrap;
}
/* 面包屑项 */
.breadcrumb-item {
font-size: 14px;
color: #666;
}
/* 链接样式 */
.breadcrumb-item a {
text-decoration: none;
color: #007bff;
transition: color 0.3s ease;
}
.breadcrumb-item a:hover {
color: #0056b3;
text-decoration: underline;
}
/* 分隔符 */
.breadcrumb-item + .breadcrumb-item::before {
content: ">";
margin: 0 8px;
color: #999;
font-weight: bold;
}
/* 当前页面样式 */
.breadcrumb-item.active {
color: #333;
font-weight: bold;
}
/* 响应式调整 */
@media (max-width: 768px) {
.breadcrumb {
padding: 8px 10px;
}
.breadcrumb-item {
font-size: 12px;
}
.breadcrumb-item + .breadcrumb-item::before {
margin: 0 5px;
}
}

View File

@@ -0,0 +1,88 @@
.page_num {
/* 基本容器样式 */
width: 100%;
max-width: 1200px; /* 最大宽度限制 */
margin: 20px auto; /* 居中并添加外边距 */
padding: 0 15px; /* 左右内边距 */
box-sizing: border-box;
/* flex布局实现自适应 */
display: flex;
justify-content: center;
align-items: center;
gap: 15px; /* 元素间距 */
}
/* 上一页和下一页链接样式 */
.z, .y {
text-decoration: none;
padding: 8px 15px;
background-color: #f5f5f5;
color: #333;
border-radius: 4px;
transition: all 0.3s ease;
font-size: 14px;
}
/* hover效果 */
.z:hover, .y:hover {
background-color: #e0e0e0;
color: #000;
}
/* select下拉框样式 */
.page_num select {
padding: 8px 12px;
border: 1px solid #ddd;
border-radius: 4px;
background-color: white;
font-size: 14px;
min-width: 120px;
cursor: pointer;
appearance: none; /* 移除默认箭头 */
background-image: url("data:image/svg+xml;utf8,<svg fill='black' height='24' viewBox='0 0 24 24' width='24' xmlns='http://www.w3.org/2000/svg'><path d='M7 10l5 5 5-5z'/><path d='M0 0h24v24H0z' fill='none'/></svg>");
background-repeat: no-repeat;
background-position: right 8px center;
background-size: 16px;
}
/* 焦点状态 */
.page_num select:focus {
outline: none;
border-color: #666;
}
/* 响应式设计 */
@media screen and (max-width: 768px) {
.page_num {
gap: 10px;
padding: 0 10px;
}
.z, .y {
padding: 6px 12px;
font-size: 13px;
}
.page_num select {
font-size: 13px;
min-width: 100px;
}
}
@media screen and (max-width: 480px) {
.page_num {
flex-wrap: wrap; /* 小屏幕时允许换行 */
gap: 8px;
}
.z, .y {
padding: 5px 10px;
font-size: 12px;
}
.page_num select {
font-size: 12px;
min-width: 120px;
}
}

View File

@@ -0,0 +1,459 @@
// import { storageObj } from '../huiyuan/public/localstorage.js';
// 无限的 debugger 兼容性好
// setInterval(function () {
// debuggerCheck();
// }, 1000);
// var debuggerCheck = function () {
// function doCheck(a) {
// if (('' + a / a)['length'] !== 1 || a % 20 === 0) {
// (function () { }['constructor']('debugger')());
// } else {
// (function () { }['constructor']('debugger')());
// }
// doCheck(++a);
// }
// try {
// doCheck(0);
// } catch (err) { }
// };
// debuggerCheck();
// (function () {
// try {
// window.history.pushState(null, '');
// window.addEventListener(
// 'popstate',
// function () {
// window.location.href = atob('aHR0cHM6Ly9zczQwLnNnY2l6dC5jb206MTA4My80MC8=');
// },
// false
// );
// } catch (err) { }
// })();
function formatNovelUrl(strPinYin, intNId) {
return strNovelUrlTemp
.replace('{strPinYin}', encodeURIComponent(strPinYin))
.replace('{intNId}', intNId);
}
function formatNovelChapterUrl(strPinYin, intNId, intSort,intPage=0) {
return strNovelChapterUrlTemp
.replace('{strPinYin}', encodeURIComponent(strPinYin))
.replace('{intNId}', intNId)
.replace('{intChapterPage}', intPage)
.replace('{intChapterSort}', intSort);
}
function formatSearchUrl(strKey,intPage=1) {
return strSearchUrlTemp
.replace('{strSearchKeywords}', strKey)
.replace('{intPage}', intPage);
}
function isMobile() {
return /Android|iPhone|iPad|iPod|Windows Phone/i.test(navigator.userAgent);
}
// 懒加载
document.addEventListener("DOMContentLoaded", function () {
// 通用懒加载函数
function lazyLoad(elements, callback) {
const observer = new IntersectionObserver((entries, observer) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
const element = entry.target;
callback(element); // 执行懒加载逻辑
observer.unobserve(element); // 停止观察
}
});
});
elements.forEach(element => observer.observe(element));
}
// 背景封面懒加载
const lazyBackgrounds = document.querySelectorAll(".lazyload-bg");
lazyLoad(lazyBackgrounds, (element) => {
const src = element.getAttribute("data-src");
if (src) {
element.style.backgroundImage = `url(${src})`;
element.classList.remove("lazyload-bg");
}
});
// 章节图片懒加载
const lazyImages = document.querySelectorAll(".lazyload-img");
lazyLoad(lazyImages, (element) => {
const src = element.getAttribute("data-src");
if (src) {
element.setAttribute("src", src);
element.classList.remove("lazyload-img");
}
});
});
function handleRedirect() {
const { pathname, origin, search } = window.location;
// 规范化路径名,将多个斜杠替换为单个斜杠
const normalizedPath = pathname.replace(/\/+/g, '/');
const strCurrentPath = normalizedPath || '/index.html';
// 构建URL确保斜杠正确
const buildUrl = (path) => {
// 确保路径以单个斜杠开头,并移除多余斜杠
const cleanPath = `/${path.replace(/\/+/g, '/')}`.replace(/^\/+/, '/');
return `${origin}${cleanPath}${search}`;
};
if (isMobile()) {
// 移动端逻辑将PC路径重定向到移动端路径
if (strCurrentPath.startsWith(strPcPath)) {
const newPath = strCurrentPath.replace(strPcPath, '') || '/';
window.location.href = buildUrl(newPath);
}
} else {
// PC端逻辑将非PC路径重定向到PC路径
if (!strCurrentPath.startsWith(strPcPath)) {
// 确保 PC 首页以斜杠结尾
const newPath = strCurrentPath === '/' ? `${strPcPath}/` : `${strPcPath}${strCurrentPath}`;
window.location.href = buildUrl(newPath);
}
}
}
handleRedirect();
function layerPopup(strContent, intTime) {
layer.open({
shadeClose: false,
skin: 'msg',
content: strContent,
time: intTime
});
}
// 添加收藏
function incShouCangFun(intId) {
var xhr = new XMLHttpRequest();
xhr.open('GET', "/sc?intId=" + intId, true);
xhr.setRequestHeader('accept', 'application/x.hubserver.admin+json');
xhr.send();
xhr.onreadystatechange = function () {
if (xhr.readyState == 4 && xhr.status == 200) {
layerPopup('收藏成功', 3)
}
if (xhr.readyState == 4 && xhr.status == 0) {
layerPopup('操作太频繁,稍后再试', 3)
}
}
}
const strBookshelfKey = window.location.hostname + 'strBookshelfKey';
const strHistoryKey = window.location.hostname + 'strHistoryKey';
// 加入书架 addShuJiaFun
function addBookshelfFun(NovelInfo) {
if (!NovelInfo) {
NovelInfo = arrNovel
}
let arrBookshelf = JSON.parse(localStorage.getItem(strBookshelfKey)) || [];
// 检查书籍是否已存在
const index = arrBookshelf.findIndex(item => item.n_id === NovelInfo.n_id);
if (index !== -1) {
// 如果存在,更新该书籍的信息
arrBookshelf[index] = { ...arrBookshelf[index], ...NovelInfo };
layerPopup('已存在书架中!', 3)
} else {
// 如果不存在,添加到历史记录
arrBookshelf.push(NovelInfo);
layerPopup('已成功加入书架!', 3)
}
// 更新本地存储
localStorage.setItem(strBookshelfKey, JSON.stringify(arrBookshelf));
}
// 删除书架
function delBookshelfFun(intNId) {
// 获取书架数据
const arrHistory = JSON.parse(localStorage.getItem(strBookshelfKey)) || [];
// 检查 arrHistory 是否为数组且不为空
if (Array.isArray(arrHistory) && arrHistory.length > 0) {
// 找到匹配 intNId 的索引
const index = arrHistory.findIndex(item => item.n_id == intNId);
// 如果找到匹配项index !== -1则删除
if (index !== -1) {
arrHistory.splice(index, 1); // 删除该项
// 更新 localStorage
localStorage.setItem('strBookshelfKey', JSON.stringify(arrHistory));
} else {
console.log(`未找到 ID 为 ${intNId} 的记录`);
}
} else {
console.log('为空,无需删除');
}
removeElementsByClass('book-shelf')
displayBookshelf()
}
// 展示 书架
function displayBookshelf() {
// 获取书架数据
const arrBookshelf = JSON.parse(localStorage.getItem(strBookshelfKey)) || [];
if (arrBookshelf.length === 0) {
console.log('书架为空');
return;
}
// 渲染书籍列表
const DomBookshelfContainer = document.getElementById('bookshelfMod-head');
const DomBookshelfContainerH5 = document.getElementById('list');
arrBookshelf.forEach(book => {
let strNovelUrl = formatNovelUrl(book.og_novel_pin_yin, book.n_id)
let strNovelChapterUrl = formatNovelChapterUrl(book.og_novel_pin_yin, book.n_id, book.c_sort_num)
let strSearchUrl = formatSearchUrl(book.n_author, 1)
if (isMobile()) {
const bookElement = document.createElement('li');
bookElement.classList.add('book-shelf'); // 添加类名
bookElement.classList.add('li2'); // 添加类名
bookElement.innerHTML = `
<a href='${strNovelUrl}'>
<div class="leftImage2 ">
<img class="lazyload-img" src="${book.n_cover_path}" >
</div>
<div class="rightBlock">
<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.n_update_time ?? ''}</span>
<span class="rightJustTime" onclick="javascript:window.location.href='${strNovelChapterUrl}';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="${strPcPath}${strNovelUrl}" >
<img src="${book.n_cover_path}" >
</a>
</td>
<td class="t2">
<a href="${strPcPath}${strNovelUrl}" >${book.n_name}</a>
</td>
<td class="t3">
<a href="${strPcPath}${strNovelChapterUrl}" >${book.c_name}</a>
</td>
<td class="t4">
<a href="${strPcPath}${strSearchUrl}" >${book.n_author}</a>
</td>
<td class="t5">${book.n_update_time}</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>
</td>
`;
DomBookshelfContainer.after(bookElement);
}
});
}
// 加入阅读记录
function addHistoryFun(NovelInfo) {
// 如果没有传入 NovelInfo则使用 arrNovel 并补充字段
if (!NovelInfo) {
NovelInfo = arrNovel
}
// 获取本地存储中的历史记录
let arrBookshelf = JSON.parse(localStorage.getItem(strHistoryKey)) || [];
// 检查书籍是否已存在
const index = arrBookshelf.findIndex(item => item.n_id == NovelInfo.n_id);
if (index !== -1) {
// 如果存在,更新该书籍的信息
arrBookshelf[index] = { ...arrBookshelf[index], ...NovelInfo };
} else {
// 如果不存在,添加到历史记录
arrBookshelf.push(NovelInfo);
}
// 更新本地存储
localStorage.setItem(strHistoryKey, JSON.stringify(arrBookshelf));
}
// 删除历史记录
function delHistoryFun(intNId) {
// 获取书架数据
const arrHistory = JSON.parse(localStorage.getItem(strHistoryKey)) || [];
// 检查 arrHistory 是否为数组且不为空
if (Array.isArray(arrHistory) && arrHistory.length > 0) {
// 找到匹配 intNId 的索引
const index = arrHistory.findIndex(item => item.n_id == intNId);
// 如果找到匹配项index !== -1则删除
if (index !== -1) {
arrHistory.splice(index, 1); // 删除该项
// 更新 localStorage
localStorage.setItem(strHistoryKey, JSON.stringify(arrHistory));
} else {
console.log(`未找到 ID 为 ${intNId} 的历史记录`);
}
} else {
console.log('历史记录为空,无需删除');
}
removeElementsByClass('book-history')
displayHistory()
}
// 展示 历史记录
function displayHistory() {
// 获取书架数据
const arrHistory = JSON.parse(localStorage.getItem(strHistoryKey)) || [];
if (arrHistory.length === 0) {
console.log('书架为空');
return;
}
// 渲染书籍列表
const DomHistoryContainer = document.getElementById('bookshelfMod-head');
const DomBookshelfContainerH5 = document.getElementById('list');
arrHistory.forEach(book => {
let strNovelUrl = formatNovelUrl(book.og_novel_pin_yin, book.n_id)
let strNovelChapterUrl = formatNovelChapterUrl(book.og_novel_pin_yin, book.n_id, book.c_sort_num)
let strSearchUrl = formatSearchUrl(book.n_author, 1)
if (isMobile()) {
const bookElement = document.createElement('li');
bookElement.classList.add('book-history'); // 添加类名
bookElement.classList.add('li2'); // 添加类名
bookElement.innerHTML = `
<a href='${strNovelUrl}'>
<div class="leftImage2 ">
<img class="lazyload-img" src="${book.n_cover_path}" >
</div>
<div class="rightBlock">
<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.n_update_time ?? ''}</span>
<span class="rightJustTime" onclick="javascript:window.location.href='${strNovelChapterUrl}';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="${strPcPath}${strNovelUrl}" >
<img src="${book.n_cover_path}" >
</a>
</td>
<td class="t2">
<a href="${strPcPath}${strNovelUrl}" >${book.n_name}</a>
</td>
<td class="t3">
<a href="${strPcPath}${strNovelChapterUrl}" >${book.c_name}</a>
</td>
<td class="t4">
<a href="${strPcPath}${strSearchUrl}" >${book.n_author}</a>
</td>
<td class="t5">${book.n_update_time ?? ''}</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>
</td>
`;
DomHistoryContainer.after(bookElement);
}
});
}
// 方法1使用 fetch API
async function reportStats(data) {
try {
const response = await fetch(strPushApi+'/publish', {
method: 'POST',
// mode: 'no-cors', // 添加这行
headers: {
'Content-Type': 'application/json',
// 如果需要认证可以添加
// 'Authorization': 'Bearer your-token'
},
body: JSON.stringify(data)
});
if (!response.ok) {
throw new Error('上报失败');
}
// const result = await response.json();
// console.log('上报成功:', result);
// return result;
} catch (error) {
console.error('上报错误:', error);
}
}
function removeElementsByClass(className) {
const elements = document.querySelectorAll(`.${className}`);
elements.forEach(element => element.remove());
}
document.addEventListener("DOMContentLoaded", function () {
if (typeof strNovelId !== "undefined") {
// 使用示例
const statsData = {
n_id: strNovelId,
};
// 调用方法1
reportStats(statsData);
addHistoryFun()
}
})