Files
o.nmgjg.com.cn/index/to-kkb.html

267 lines
8.2 KiB
HTML
Raw Normal View History

2026-01-29 00:11:34 +08:00
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>客客邦文档库</title>
<style>
body {
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
background-color: #f9fbfd;
margin: 0;
padding: 0;
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
color: #333;
line-height: 1.6;
}
.container {
text-align: center;
padding: 24px;
background: white;
border-radius: 12px;
box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
max-width: 700px;
width: 92%;
margin: 16px;
}
h2 {
margin: 0 0 16px;
color: #2c3e50;
font-size: 22px;
}
#readme-area {
text-align: left;
padding: 16px;
background: #fafafa;
border-radius: 8px;
min-height: 40px;
/* max-height: 70%; */
overflow-y: auto;
margin: 16px 0;
font-size: 15px;
color: #444;
}
/* Marked 默认样式微调 */
#readme-area h1,
#readme-area h2,
#readme-area h3 {
margin: 14px 0 10px;
color: #2c3e50;
}
#readme-area ul,
#readme-area ol {
padding-left: 24px;
margin: 10px 0;
}
#readme-area li {
margin: 6px 0;
}
#readme-area p {
margin: 10px 0;
}
.confirm-btn {
margin-top: 12px;
padding: 10px 24px;
background-color: #2ecc71;
color: white;
border: none;
border-radius: 6px;
cursor: pointer;
font-size: 16px;
font-weight: 500;
}
.confirm-btn:hover:not(:disabled) {
background-color: #27ae60;
}
.confirm-btn:disabled {
background-color: #bdc3c7;
cursor: not-allowed;
}
.error-container {
display: none;
}
.debug-section {
margin-top: 20px;
padding: 14px;
background: #f8f9fa;
border: 1px solid #eee;
border-radius: 8px;
font-size: 13px;
text-align: left;
color: #666;
}
.debug-section h4 {
margin-top: 0;
color: #777;
font-size: 15px;
border-bottom: 1px dashed #ddd;
padding-bottom: 6px;
}
.debug-line {
margin: 4px 0;
}
.label {
font-weight: bold;
color: #333;
display: inline-block;
width: 60px;
}
@media (max-width: 600px) {
.container {
padding: 20px 16px;
}
h2 {
font-size: 20px;
}
#readme-area {
font-size: 14px;
padding: 14px;
}
}
</style>
</head>
<body>
<!-- 引入 marked -->
<script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
<div class="container" id="main-container">
<h2>客客邦文档库</h2>
<div id="readme-area">加载中...</div>
<button id="confirm-btn" class="confirm-btn" style="display: none;" onclick="startRedirect()">我已阅读,继续跳转</button>
</div>
<div class="container error-container" id="error-container">
<h2>⚠️ 跳转失败</h2>
<p>未能成功跳转到目标页面,请检查网络或稍后重试。</p>
<button class="confirm-btn" onclick="location.reload()">点击重试</button>
<div class="debug-section">
<h4>调试信息</h4>
<div class="debug-line"><span class="label">时间:</span><span id="debug-time"></span></div>
<div class="debug-line"><span class="label">地址:</span><span id="debug-url"></span></div>
<div class="debug-line"><span class="label">错误:</span><span id="debug-error"></span></div>
</div>
</div>
<script>
let redirectAttempted = false;
const TXT_URL = "https://o.nmgjg.com.cn/wiki.txt";
const README_URL = "https://o.nmgjg.com.cn/wiki_readme.md";
// 获取目标路径:优先使用 ?url=xxx否则用当前 pathname
function getTargetPath() {
const params = new URLSearchParams(window.location.search);
let path = params.get('url');
if (path !== null) {
// 检查是否是完整URL格式如果是则提取路径部分
try {
const url = new URL(path);
return url.pathname + url.search + url.hash;
} catch (e) {
// 如果不是完整URL则按原逻辑处理
return path.startsWith('/') ? path : '/' + path;
}
}
return window.location.pathname;
}
// 跳转函数
function doRedirect(url) {
redirectAttempted = true;
window.location.href = url;
setTimeout(() => {
if (redirectAttempted) {
showError("跳转未生效,请检查网络或地址");
}
}, 5000);
}
// 显示错误
function showError(msg) {
document.getElementById("debug-error").textContent = msg;
document.getElementById("main-container").style.display = "none";
document.getElementById("error-container").style.display = "block";
}
// 开始跳转流程(读取 wiki.txt 并拼接路径)
function startRedirect() {
const btn = document.getElementById("confirm-btn");
if (btn.style.display !== "none") {
btn.disabled = true;
btn.textContent = "跳转中...";
} else {
document.getElementById("readme-area").textContent = "跳转中...";
}
fetch(TXT_URL, { cache: "no-cache" })
.then(res => {
if (!res.ok) throw new Error(`HTTP ${res.status}`);
return res.text();
})
.then(text => {
const ipPort = text.trim();
if (!ipPort) throw new Error("IP:Port 为空");
const targetUrl = `http://${ipPort}${getTargetPath()}`;
doRedirect(targetUrl);
})
.catch(err => {
showError(err.message || String(err));
});
}
// 页面初始化
document.addEventListener("DOMContentLoaded", () => {
document.getElementById("debug-time").textContent = new Date().toLocaleString('zh-CN');
document.getElementById("debug-url").textContent = window.location.href;
const hasUrlParam = new URLSearchParams(window.location.search).has('url');
if (hasUrlParam) {
// 有 url 参数:跳过 README直接跳转
startRedirect();
} else {
// 无参数:加载并渲染 README
fetch(README_URL, { cache: "no-cache" })
.then(res => {
if (!res.ok) throw new Error('加载失败');
return res.text();
})
.then(mdText => {
// 使用 marked 渲染
const html = marked.parse(mdText, { gfm: true, breaks: true });
document.getElementById("readme-area").innerHTML = html;
document.getElementById("confirm-btn").style.display = "inline-block";
})
.catch(() => {
// README 加载失败:静默跳转
startRedirect();
});
}
});
</script>
</body>
</html>