index.html
4.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>项目文档导航 — $project</title>
<style>
$CSS
.page-header { text-align: center; margin-bottom: 40px; }
.page-header h1 { font-size: 1.75rem; margin-bottom: 8px; }
.page-header .subtitle { color: var(--color-text-secondary); font-size: 0.95rem; }
.page-header .meta { margin-top: 12px; display: flex; justify-content: center; gap: 16px; flex-wrap: wrap; }
.page-header .meta-item { font-size: 0.8rem; color: var(--color-text-muted); background: var(--color-bg); padding: 4px 12px; border-radius: 12px; border: 1px solid var(--color-border); }
.rerender-btn { position: fixed; bottom: 24px; right: 24px; z-index: 999; padding: 10px 20px; background: #2563eb; color: #fff; border: none; border-radius: 8px; font-size: 0.9rem; cursor: pointer; box-shadow: 0 2px 8px rgba(37,99,235,0.3); transition: background 0.15s, transform 0.15s; }
.rerender-btn:hover { background: #1d4ed8; transform: translateY(-1px); }
.rerender-btn:disabled { background: #94a3b8; cursor: not-allowed; transform: none; }
.rerender-overlay { display: none; position: fixed; inset: 0; z-index: 1000; background: rgba(0,0,0,0.5); align-items: center; justify-content: center; }
.rerender-overlay.active { display: flex; }
.rerender-modal { background: #fff; border-radius: 12px; padding: 24px; max-width: 600px; width: 90%; max-height: 80vh; display: flex; flex-direction: column; box-shadow: 0 8px 32px rgba(0,0,0,0.2); }
.rerender-modal h3 { margin-bottom: 12px; font-size: 1rem; }
.rerender-output { flex: 1; overflow-y: auto; background: #1e293b; color: #e2e8f0; padding: 12px; border-radius: 6px; font-size: 0.8rem; line-height: 1.5; white-space: pre-wrap; word-break: break-all; min-height: 120px; }
</style>
</head>
<body>
<div class="container">
<header class="page-header">
<h1>🧙 Magic-Vision-Spec — 项目文档导航</h1>
<p class="subtitle">$project · 全流程开发规约可视化文档</p>
<div class="meta">
<span class="meta-item">📌 v$version</span>
<span class="meta-item">🕐 更新:$date</span>
</div>
</header>
<div id="cards"></div>
</div>
<footer class="footer">Magic-Vision-Spec · 由 AI 生成的自包含可视化文档集</footer>
<button class="rerender-btn" onclick="rerender()" id="rerenderBtn">重新渲染</button>
<div class="rerender-overlay" id="rerenderOverlay">
<div class="rerender-modal">
<h3>正在重新渲染...</h3>
<pre id="rerenderOutput" class="rerender-output"></pre>
</div>
</div>
<script>
const CATEGORIES = $categories_json;
function render() {
const container = document.getElementById('cards');
container.innerHTML = CATEGORIES.map(cat => {
const files = cat.files || [];
const hasFiles = files.length > 0;
const showFold = files.length > 5;
const visible = showFold ? files.slice(0, 5) : files;
const folded = showFold ? files.slice(5) : [];
return `<div class="nav-card">
<div class="nav-card-header">
<span class="nav-card-title"><span class="nav-card-icon">${cat.icon || '📄'}</span>${cat.title}</span>
<span class="nav-card-date">${cat.date || '—'}</span>
</div>
<div class="nav-card-body${hasFiles ? '' : ' empty'}">
${hasFiles
? visible.map(f => `<a href="${f.href}" class="nav-file-link">
<span class="file-icon">📄</span>${f.name || f.href.split('/').pop()}
${f.desc ? `<span class="file-desc">${f.desc}</span>` : ''}
</a>`).join('')
+ (folded.length ? `<details class="accordion" style="margin:0;border:none;border-top:1px solid var(--color-border)">
<summary class="accordion-summary" style="font-weight:400;font-size:0.82rem;color:var(--color-text-secondary)">展开全部 (${folded.length} 项)</summary>
<div class="accordion-content" style="padding:0">`
+ folded.map(f => `<a href="${f.href}" class="nav-file-link">
<span class="file-icon">📄</span>${f.name || f.href.split('/').pop()}
${f.desc ? `<span class="file-desc">${f.desc}</span>` : ''}
</a>`).join('')
+ `</div></details>` : '')
: '<div class="empty">尚未生成</div>'
}
</div>
</div>`;
}).join('');
}
render();
async function rerender() {
const btn = document.getElementById('rerenderBtn');
const overlay = document.getElementById('rerenderOverlay');
const output = document.getElementById('rerenderOutput');
btn.disabled = true;
overlay.classList.add('active');
output.textContent = '正在重新渲染,请稍候...\n';
try {
const resp = await fetch('/rerender', { method: 'POST' });
const text = await resp.text();
output.textContent = text;
output.textContent += '\n渲染完成!页面即将刷新...';
setTimeout(() => location.reload(), 1000);
} catch (e) {
output.textContent += '\n[ERROR] ' + e.message;
btn.disabled = false;
}
}
</script>
</body>
</html>