diff --git a/login.php b/login.php index c637c26..3bc46ac 100644 --- a/login.php +++ b/login.php @@ -91,9 +91,18 @@ require_once __DIR__ . '/captcha_guard.php'; .ag-modal .ag-close { cursor: pointer; color: var(--dim); font-size: 20px; line-height: 1; } .ag-body { padding: 14px 18px; overflow-y: auto; flex: 1; - font-size: 13px; line-height: 1.75; color: var(--text); white-space: pre-wrap; + font-size: 13px; line-height: 1.75; color: var(--text); white-space: normal; word-break: break-word; } + /* 协议 markdown 渲染样式(标题/列表/加粗/引用/代码/段落) */ + .ag-body h1, .ag-body .ag-h { font-size: 18px; font-weight: 700; color: var(--accent); margin: 14px 0 8px; } + .ag-body .ag-h2 { font-size: 15px; font-weight: 700; color: var(--accent); margin: 12px 0 6px; } + .ag-body .ag-h3 { font-size: 14px; font-weight: 600; color: var(--text); margin: 10px 0 5px; } + .ag-body ul { margin: 6px 0 8px 4px; padding-left: 18px; } + .ag-body li { margin: 3px 0; } + .ag-body .ag-quote { border-left: 3px solid var(--yellow); padding: 6px 12px; margin: 8px 0; background: rgba(210,153,34,0.08); border-radius: 4px; } + .ag-body code { background: rgba(136,136,136,0.2); padding: 1px 5px; border-radius: 3px; font-size: 0.9em; } + .ag-body .ag-p { margin: 4px 0; } .ag-foot { padding: 12px 18px; border-top: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; gap: 10px; @@ -333,7 +342,7 @@ require_once __DIR__ . '/captcha_guard.php'; const res = await fetch(url, { method: 'POST', headers: {'Content-Type': 'application/json'} }); const data = await res.json(); if (data.success && data.data && data.data.has_agreement && (data.data.content || '').trim() !== '') { - body.textContent = data.data.content; + body.innerHTML = renderMarkdownLite(data.data.content); // ★ 渲染 markdown(标题/列表/加粗/引用) document.getElementById('agModalTitle').textContent = data.data.title || AG.title; AG_LOADED = true; // ★ 原文到位 AG_HAS_CONTENT = true; // ★ 有实际内容 @@ -402,6 +411,62 @@ require_once __DIR__ . '/captcha_guard.php'; } // 点「我已完成阅读」→ 关闭弹窗并自动勾选 + // ===== 轻量 markdown → HTML 渲染(登录弹窗用,无外部依赖,与 player.php 同范式)===== + function renderMarkdownLite(md) { + if (!md) return ''; + const lines = String(md).split(/\r?\n/); + let html = ''; + let inList = false; + const closeList = () => { if (inList) { html += ''; 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; } + // 标题 #/##/### + const hm = s.match(/^(#{1,6})\s+(.*)$/); + if (hm) { + closeList(); + const lvl = hm[1].length; + const cls = lvl <= 2 ? (lvl === 1 ? 'ag-h' : 'ag-h2') : 'ag-h3'; + html += `
${inlineMd(hm[2])}
`; + continue; + } + // 无序列表 -/*/+ + if (s.match(/^\s*[-*+]\s+/)) { + if (!inList) { html += '