diff --git a/static/index.html b/static/index.html
index 44d0ed4c..c9a59989 100644
--- a/static/index.html
+++ b/static/index.html
@@ -1932,35 +1932,40 @@ function inMd(t) {
// ── 📚 文档 Tab(2026-08-11 新增,开源项目式文档体系)──
let _docsState = { loaded: false, currentPath: null, view: 'tree' }; // tree | versions | read
+// ── 📚 文档 Tab(2026-08-11 重构为左右布局:左侧栏目录 + 右侧内容)──
+let _docsState = { currentPath: null, tree: null };
+
async function renderDocs() {
const el = document.getElementById('tab-docs');
if (!el) return;
el.innerHTML =
- '
' +
- '
' + cat + '
' +
+ html += '
' +
+ '
' + cat + '
' +
'
' +
docs.map(d =>
- '
' +
- (d.core ? '⭐ ' : '📄 ') + d.title + '
'
+ '
' +
+ (d.core ? '⭐ ' : '') + d.title + '
'
).join('') +
'
';
}
- body.innerHTML = html;
+ tree.innerHTML = html;
+ // 高亮当前选中项
+ _docsHighlight();
}
-async function _renderDocsVersions() {
- const body = document.getElementById('docs-body');
- const data = await fetchJSON('/api/docs/versions');
- if (!data.ok) {
- body.innerHTML = '
' + (data.error || '加载失败') + '
';
- return;
+function _docsHighlight() {
+ document.querySelectorAll('#docs-tree [title]').forEach(el => el.classList.remove('bg-slate-800', 'text-blue-400'));
+ if (_docsState.currentPath) {
+ document.querySelectorAll('#docs-tree [title="' + _docsState.currentPath + '"]').forEach(el => {
+ el.classList.add('bg-slate-800', 'text-blue-400');
+ });
}
- body.innerHTML = data.versions.map(v => {
- const parts = v.title.split('—');
- const date = parts[0].trim();
- const title = parts.slice(1).join('—').trim() || v.title;
- return '
' +
- '
' + date + '
' +
- '
' + title + '
' +
- '
' + v.body + '
' +
- '
';
- }).join('');
}
async function _docsRead(path) {
- _docsState.view = 'read';
_docsState.currentPath = path;
- const body = document.getElementById('docs-body');
- const navBar = body.closest('#tab-docs').querySelector('.flex.gap-2');
- // 更新导航显示当前路径
+ _docsHighlight();
+ const content = document.getElementById('docs-content');
+ if (!content) return;
+ content.innerHTML = '
加载中...
';
const data = await fetchJSON('/api/docs/read?path=' + encodeURIComponent(path));
if (!data.ok) {
- body.innerHTML = '
' + (data.error || '加载失败') + '
';
+ content.innerHTML = '
' + (data.error || '加载失败') + '
';
return;
}
- body.innerHTML =
- '
' +
- '' +
- '' + path + '' +
- '
' +
- '
' + inMd(data.content) + '
';
+ // 版本变更用特殊排版(日期+标题+正文分段)
+ if (path === 'VERSIONS.md') {
+ content.innerHTML = _renderVersionsHTML(data.content);
+ } else {
+ content.innerHTML =
+ '
📄 ' + path + '
' +
+ '
' + inMd(data.content) + '
';
+ }
+}
+
+function _renderVersionsHTML(md) {
+ // 解析 VERSIONS.md:按 ## 分段,每段一个版本卡片
+ const parts = md.split(/^##\s+/m).filter(p => p.trim() && !p.startsWith('阅读指南') && !p.startsWith('维护说明'));
+ const cards = parts.map(p => {
+ const lines = p.split('\n');
+ const title = lines[0].trim();
+ const body = lines.slice(1).join('\n').trim();
+ return '
' +
+ '
' + title + '
' +
+ '
' + inMd(body) + '
' +
+ '
';
+ }).join('');
+ return '
📜 版本变更记录(给运营者的详细说明)
' + cards;
}
function renderResearch() {