125续15l-5: 后台玩家签署情况板块 + 玩家端查看协议原文
- admin.php: 侧边栏加'📜 用户协议'(data-p=rules), go('rules')→loadRules 后台视角=玩家签署情况: 已签总数/当前版本已签/旧版本待重签 + 签署记录倒序表 (玩家名/签署时间/版本状态徽章), 调 api/sync.php?action=rules_content rules目录无.md 时后台提示未配置 - player.php: 侧边栏加'📜 用户协议', switchPage('rules')→renderRules 玩家端视角=查看协议原文: 轻量markdown渲染(标题/列表/加粗/引用/代码/链接), 无外部依赖 展示版本指纹+行数; rules目录无.md 时提示未配置
This commit is contained in:
+94
@@ -381,6 +381,7 @@ if ($currentVersion !== $BUILD_VERSION) {
|
||||
<div class="sidebar-item" data-page="sn" onclick="switchPage('sn')">🔢 SN设备管理</div>
|
||||
<div class="sidebar-item" data-page="account" onclick="switchPage('account')">🛡️ 账号安全</div>
|
||||
<div class="sidebar-item" data-page="credit" onclick="switchPage('credit')">⭐ 信誉积分</div>
|
||||
<div class="sidebar-item" data-page="rules" onclick="switchPage('rules')">📜 用户协议</div>
|
||||
</div>
|
||||
|
||||
<div class="content" id="content">
|
||||
@@ -1273,6 +1274,99 @@ if ($currentVersion !== $BUILD_VERSION) {
|
||||
else if (page === 'credit') renderCredit(c);
|
||||
else if (page === 'recharge') renderRecharge(c);
|
||||
else if (page === 'orders') renderMyOrders(c);
|
||||
else if (page === 'rules') renderRules(c);
|
||||
}
|
||||
|
||||
// ==================== 用户协议(玩家端查看协议原文) ====================
|
||||
// 数据源:api/sync.php?action=rules_content(读 Web 目录 rules/*.md)
|
||||
// rules 目录无 .md → 提示"服务器未配置用户协议"
|
||||
async function renderRules(el) {
|
||||
el.innerHTML = `<div class="card" style="text-align:center;padding:40px;color:var(--dim)">正在加载用户协议...</div>`;
|
||||
let d = null;
|
||||
try {
|
||||
const res = await fetch('api/sync.php?action=rules_content', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
credentials: 'same-origin'
|
||||
});
|
||||
const json = await res.json();
|
||||
if (json.success && json.data) d = json.data;
|
||||
} catch (e) {
|
||||
el.innerHTML = `<div class="card" style="padding:24px;color:var(--red)">协议加载失败:${e.message}</div>`;
|
||||
return;
|
||||
}
|
||||
if (!d || d.skipped || !d.has_agreement) {
|
||||
el.innerHTML = `<div class="card" style="padding:24px">
|
||||
<h2 style="margin:0 0 10px">📜 用户协议</h2>
|
||||
<p style="color:var(--dim)">服务器当前未配置用户协议(rules 目录无协议文件)。</p>
|
||||
</div>`;
|
||||
return;
|
||||
}
|
||||
// 渲染:用 <pre-wrap> 原文 + 简单 markdown 转 html(标题/列表/加粗),不引入外部依赖
|
||||
el.innerHTML = `<div class="card" style="max-width:760px">
|
||||
<div style="display:flex;justify-content:space-between;align-items:center;margin-bottom:12px;flex-wrap:wrap;gap:8px">
|
||||
<h2 style="margin:0">📜 ${esc(d.title || '服务器用户协议')}</h2>
|
||||
<button class="btn btn-dim" onclick="renderRules(document.getElementById('content'))" style="font-size:12px;padding:6px 12px">🔄 刷新</button>
|
||||
</div>
|
||||
<div class="rules-body" style="line-height:1.85;font-size:14px;white-space:pre-wrap;word-break:break-word;color:var(--text)">
|
||||
${renderMarkdownLite(d.content)}
|
||||
</div>
|
||||
<p style="color:var(--dim);font-size:12px;margin-top:16px">协议版本指纹:${esc(d.fingerprint || '')} | 共 ${d.line_count || 0} 行</p>
|
||||
</div>`;
|
||||
}
|
||||
|
||||
// 轻量 markdown → HTML(仅处理标题/无序列表/加粗/表格分隔线/引用/代码/链接,足够展示协议)
|
||||
function renderMarkdownLite(md) {
|
||||
if (!md) return '';
|
||||
const lines = String(md).split('\n');
|
||||
let html = '';
|
||||
let inList = false;
|
||||
const closeList = () => { if (inList) { html += '</ul>'; inList = false; } };
|
||||
for (let raw of lines) {
|
||||
let s = raw;
|
||||
// 表格分隔线丢弃
|
||||
if (s.trim().match(/^\|?[\s:|-]+\|?$/) && s.trim().length > 1 && s.includes('-')) { closeList(); continue; }
|
||||
// 代码围栏 ``` 整行丢弃(json 动作配置已在后端剥离,双保险)
|
||||
if (s.trim().startsWith('```')) { closeList(); continue; }
|
||||
// 标题
|
||||
if (s.match(/^#{1,6}\s/)) {
|
||||
closeList();
|
||||
const lvl = s.match(/^#+/)[0].length;
|
||||
const txt = s.replace(/^#+\s*/, '');
|
||||
const sz = Math.max(15, 22 - lvl);
|
||||
html += `<div style="font-size:${sz}px;font-weight:700;color:var(--accent);margin:14px 0 8px">${esc(txt)}</div>`;
|
||||
continue;
|
||||
}
|
||||
// 无序列表
|
||||
if (s.match(/^\s*[-*+]\s+/)) {
|
||||
if (!inList) { html += '<ul style="margin:6px 0 6px 20px;padding:0">'; inList = true; }
|
||||
const item = s.replace(/^\s*[-*+]\s+/, '');
|
||||
html += `<li style="margin:3px 0">${inlineMd(item)}</li>`;
|
||||
continue;
|
||||
}
|
||||
closeList();
|
||||
// 引用
|
||||
if (s.match(/^\s*>/)) {
|
||||
html += `<div style="border-left:3px solid var(--yellow);padding:6px 12px;margin:8px 0;background:rgba(210,153,34,0.08);border-radius:4px">${inlineMd(s.replace(/^\s*>\s?/, ''))}</div>`;
|
||||
continue;
|
||||
}
|
||||
// 空行
|
||||
if (s.trim() === '') { html += '<div style="height:8px"></div>'; continue; }
|
||||
// 普通段落
|
||||
html += `<div style="margin:4px 0">${inlineMd(s)}</div>`;
|
||||
}
|
||||
closeList();
|
||||
return html;
|
||||
}
|
||||
|
||||
// 行内 markdown:加粗/斜体/代码/链接
|
||||
function inlineMd(s) {
|
||||
let t = esc(s);
|
||||
t = t.replace(/`([^`]*)`/g, '<code style="background:rgba(136,136,136,0.2);padding:1px 5px;border-radius:3px;font-size:0.9em">$1</code>');
|
||||
t = t.replace(/(\*\*|__)(.+?)\1/g, '<b>$2</b>');
|
||||
t = t.replace(/(^|[^*])(\*)([^*]+)\*(?!\*)/g, '$1<i>$3</i>');
|
||||
t = t.replace(/\[([^\]]+)\]\(([^)]+)\)/g, '<a href="$2" target="_blank" rel="noopener" style="color:var(--accent);text-decoration:underline">$1</a>');
|
||||
return t;
|
||||
}
|
||||
|
||||
// ==================== 债券在线充值(动态加载商品) ====================
|
||||
|
||||
Reference in New Issue
Block a user