debug
This commit is contained in:
@@ -31,10 +31,60 @@
|
||||
// } 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);
|
||||
}
|
||||
|
||||
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({
|
||||
Reference in New Issue
Block a user