178 lines
11 KiB
HTML
178 lines
11 KiB
HTML
<!doctype html>
|
|
<html lang="zh-CN">
|
|
<head>
|
|
<meta charset="utf-8" />
|
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
<link rel="icon" href="data:," />
|
|
<title>{{TITLE}}</title>
|
|
<style>
|
|
:root { color-scheme: dark; --bg:#0f1419; --panel:#17212b; --line:#2a3a45; --text:#dbe6ee; --muted:#93a6b3; --accent:#73c6d4; --warn:#e0b15c; --ok:#7fc98b; }
|
|
* { box-sizing: border-box; }
|
|
html { scroll-behavior: smooth; }
|
|
body { margin:0; background:var(--bg); color:var(--text); font:15px/1.7 system-ui,"Noto Sans SC",sans-serif; }
|
|
a { color:var(--accent); text-decoration:none; }
|
|
header.top { position:sticky; top:0; z-index:30; display:flex; align-items:center; gap:12px; padding:10px 18px; background:#0b1116f2; border-bottom:1px solid var(--line); backdrop-filter:blur(6px); }
|
|
header.top h1 { margin:0; font-size:17px; flex:0 0 auto; }
|
|
#search { margin-left:auto; width:min(420px,42vw); background:#0b1014; color:var(--text); border:1px solid #3f3f3f; border-radius:6px; padding:6px 10px; }
|
|
#search-results { position:fixed; top:52px; right:18px; width:min(520px,90vw); max-height:60vh; overflow:auto; background:#0d1318; border:1px solid var(--line); border-radius:8px; box-shadow:0 12px 32px #0008; z-index:40; display:none; }
|
|
#search-results a { display:block; padding:8px 12px; border-bottom:1px solid #1d2a33; color:var(--text); }
|
|
#search-results a small { display:block; color:var(--muted); }
|
|
#menu-toggle { display:none; background:transparent; color:var(--text); border:1px solid #3f3f3f; border-radius:4px; padding:4px 8px; }
|
|
.layout { display:grid; grid-template-columns:290px minmax(0,1fr); gap:0; max-width:1500px; margin:0 auto; }
|
|
nav.sidebar { position:sticky; top:53px; height:calc(100vh - 53px); overflow:auto; border-right:1px solid var(--line); padding:14px 12px 40px; }
|
|
nav.sidebar .progress { height:8px; background:var(--panel); border-radius:4px; overflow:hidden; margin:6px 0 12px; }
|
|
nav.sidebar .progress span { display:block; height:100%; width:0; background:var(--accent); }
|
|
nav.sidebar ol { list-style:none; margin:0; padding:0; }
|
|
nav.sidebar li { margin:2px 0; }
|
|
nav.sidebar a { display:block; padding:4px 6px; border-radius:4px; color:var(--text); font-size:13.5px; }
|
|
nav.sidebar a:hover, nav.sidebar a.active { background:#22313b; color:var(--accent); }
|
|
nav.sidebar .chapter { display:flex; align-items:center; gap:6px; margin-top:8px; }
|
|
nav.sidebar .chapter input { accent-color:var(--accent); }
|
|
nav.sidebar .sec { padding-left:16px; color:var(--muted); font-size:12.5px; }
|
|
main { padding:24px 30px 80px; min-width:0; }
|
|
main h1 { font-size:26px; margin:0 0 14px; }
|
|
main h2 { font-size:20px; margin:36px 0 12px; padding-top:8px; border-top:1px solid var(--line); color:var(--accent); }
|
|
main h3 { font-size:16px; margin:24px 0 8px; }
|
|
main p, main li { max-width:900px; }
|
|
main img { display:block; max-width:100%; height:auto; border:1px solid var(--line); border-radius:8px; background:#0d1318; margin:12px 0; cursor:zoom-in; }
|
|
main figure { margin:16px 0; }
|
|
main figcaption { color:var(--muted); font-size:12.5px; }
|
|
.table-scroll { max-width:100%; overflow-x:auto; }
|
|
table { width:100%; border-collapse:collapse; font-size:13px; margin:12px 0; }
|
|
th, td { border-bottom:1px solid var(--line); padding:5px 7px; text-align:left; vertical-align:top; }
|
|
th { color:var(--accent); }
|
|
code, pre { background:#0b1014; border:1px solid #22303a; border-radius:5px; }
|
|
code { padding:1px 4px; font-size:12.5px; overflow-wrap:anywhere; }
|
|
pre { padding:10px; overflow:auto; max-width:100%; white-space:pre-wrap; overflow-wrap:anywhere; }
|
|
blockquote { border-left:3px solid var(--warn); margin:12px 0; padding:4px 12px; color:var(--warn); background:#1d1a1210; }
|
|
.cmd { font-family:ui-monospace,monospace; font-size:12px; color:#9fd6de; }
|
|
.badge { display:inline-block; border-radius:4px; padding:0 6px; font-size:11px; border:1px solid var(--line); }
|
|
.badge.detailed { color:var(--ok); } .badge.overview { color:var(--accent); } .badge.boundary { color:var(--warn); }
|
|
.index-controls { display:flex; gap:8px; flex-wrap:wrap; margin:12px 0; }
|
|
.index-controls select, .index-controls input { background:#0b1014; color:var(--text); border:1px solid #3f3f3f; border-radius:4px; padding:5px 8px; }
|
|
#command-index td { font-size:12px; } #command-index tr.hidden { display:none; }
|
|
.pager { display:flex; justify-content:space-between; gap:12px; margin-top:40px; padding-top:14px; border-top:1px solid var(--line); }
|
|
#lightbox { position:fixed; inset:0; background:#000d; z-index:60; display:none; align-items:center; justify-content:center; padding:24px; }
|
|
#lightbox img { max-width:96vw; max-height:92vh; border-radius:6px; }
|
|
#lightbox.open { display:flex; }
|
|
@media (max-width:900px) {
|
|
.layout { grid-template-columns:1fr; }
|
|
nav.sidebar { position:fixed; z-index:35; top:53px; left:0; width:280px; background:#0d1318; transform:translateX(-100%); transition:transform .2s; }
|
|
nav.sidebar.open { transform:translateX(0); }
|
|
#menu-toggle { display:inline-block; }
|
|
main { padding:18px 14px 60px; overflow-x:clip; }
|
|
header.top { gap:8px; padding:8px 10px; }
|
|
header.top h1 { font-size:14px; max-width:34vw; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
|
|
#search { width:auto; flex:1; min-width:0; margin-left:6px; }
|
|
}
|
|
@media print { header.top, nav.sidebar, #lightbox, .pager { display:none; } .layout { display:block; } main { padding:0; } main img { break-inside:avoid; } }
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<header class="top">
|
|
<button id="menu-toggle" aria-label="Toggle navigation">☰</button>
|
|
<h1>{{TITLE}}</h1>
|
|
<input id="search" type="search" placeholder="搜索章节、命令、参数…(/ 聚焦)" aria-label="搜索教案" />
|
|
</header>
|
|
<div id="search-results" role="listbox" aria-label="搜索结果"></div>
|
|
<div class="layout">
|
|
<nav class="sidebar" id="sidebar" aria-label="章节目录">
|
|
<strong>课程进度</strong>
|
|
<div class="progress"><span id="progress-bar"></span></div>
|
|
<p id="progress-text" style="color:var(--muted);font-size:12px;margin:0 0 8px"></p>
|
|
{{SIDEBAR}}
|
|
</nav>
|
|
<main id="content">
|
|
{{CONTENT}}
|
|
{{COMMAND_INDEX}}
|
|
<div class="pager" id="pager"></div>
|
|
</main>
|
|
</div>
|
|
<div id="lightbox" role="dialog" aria-label="图片预览"><img alt="" /></div>
|
|
<script>
|
|
const SEARCH_INDEX = {{SEARCH_INDEX}};
|
|
const COMMAND_COUNT = {{COMMAND_COUNT}};
|
|
const boxes = [...document.querySelectorAll('input[data-progress]')];
|
|
const key = 'web-freecad-manual-progress-v1';
|
|
const loadProgress = () => { try { return JSON.parse(localStorage.getItem(key) || '{}'); } catch { return {}; } };
|
|
const saveProgress = value => localStorage.setItem(key, JSON.stringify(value));
|
|
const renderProgress = () => {
|
|
const done = boxes.filter(box => box.checked).length;
|
|
document.getElementById('progress-bar').style.width = boxes.length ? (100 * done / boxes.length) + '%' : '0';
|
|
document.getElementById('progress-text').textContent = done + ' / ' + boxes.length + ' 章已完成';
|
|
};
|
|
const state = loadProgress();
|
|
for (const box of boxes) {
|
|
box.checked = Boolean(state[box.dataset.progress]);
|
|
box.addEventListener('change', () => { const value = loadProgress(); value[box.dataset.progress] = box.checked; saveProgress(value); renderProgress(); });
|
|
}
|
|
renderProgress();
|
|
const sidebar = document.getElementById('sidebar');
|
|
document.getElementById('menu-toggle').addEventListener('click', () => sidebar.classList.toggle('open'));
|
|
for (const link of sidebar.querySelectorAll('a[href^="#"]')) link.addEventListener('click', () => sidebar.classList.remove('open'));
|
|
|
|
const search = document.getElementById('search');
|
|
const results = document.getElementById('search-results');
|
|
const normalize = text => String(text || '').toLowerCase().replace(/\s+/g, ' ').trim();
|
|
const renderResults = query => {
|
|
const q = normalize(query);
|
|
results.innerHTML = '';
|
|
if (q.length < 1) { results.style.display = 'none'; return; }
|
|
const hits = SEARCH_INDEX.filter(item => normalize(item.title + ' ' + item.text + ' ' + (item.commands || []).join(' ')).includes(q)).slice(0, 30);
|
|
for (const hit of hits) {
|
|
const link = document.createElement('a');
|
|
link.href = '#' + hit.id;
|
|
link.innerHTML = '<strong>' + hit.title + '</strong><small>' + hit.chapter + ' · ' + hit.text.slice(0, 90).replace(/</g, '<') + '</small>';
|
|
results.appendChild(link);
|
|
}
|
|
if (!hits.length) results.innerHTML = '<p style="padding:10px;color:#93a6b3">没有匹配结果</p>';
|
|
results.style.display = 'block';
|
|
};
|
|
search.addEventListener('input', () => renderResults(search.value));
|
|
search.addEventListener('keydown', event => { if (event.key === 'Escape') { results.style.display = 'none'; search.blur(); } });
|
|
document.addEventListener('keydown', event => {
|
|
if (event.key === '/' && document.activeElement !== search) { event.preventDefault(); search.focus(); }
|
|
if (event.key === 'Escape') document.getElementById('lightbox').classList.remove('open');
|
|
});
|
|
results.addEventListener('click', event => { if (event.target.closest('a')) results.style.display = 'none'; });
|
|
|
|
const lightbox = document.getElementById('lightbox');
|
|
for (const image of document.querySelectorAll('main img')) {
|
|
image.addEventListener('click', () => { lightbox.querySelector('img').src = image.src; lightbox.classList.add('open'); });
|
|
}
|
|
lightbox.addEventListener('click', () => lightbox.classList.remove('open'));
|
|
|
|
const moduleFilter = document.getElementById('filter-module');
|
|
const statusFilter = document.getElementById('filter-status');
|
|
const indexSearch = document.getElementById('filter-command');
|
|
const rows = [...document.querySelectorAll('#command-index tbody tr')];
|
|
const applyFilter = () => {
|
|
const module = moduleFilter?.value || '';
|
|
const status = statusFilter?.value || '';
|
|
const text = normalize(indexSearch?.value || '');
|
|
for (const row of rows) {
|
|
const ok = (!module || row.dataset.module === module) && (!status || row.dataset.status === status)
|
|
&& (!text || normalize(row.textContent).includes(text));
|
|
row.classList.toggle('hidden', !ok);
|
|
}
|
|
};
|
|
for (const control of [moduleFilter, statusFilter, indexSearch]) control?.addEventListener('input', applyFilter);
|
|
|
|
const heads = [...document.querySelectorAll('main h2[id]')];
|
|
const links = new Map([...sidebar.querySelectorAll('a[href^="#"]')].map(link => [link.getAttribute('href').slice(1), link]));
|
|
const spy = () => {
|
|
let current = null;
|
|
for (const head of heads) if (head.getBoundingClientRect().top < 120) current = head.id;
|
|
for (const [id, link] of links) link.classList.toggle('active', id === current);
|
|
};
|
|
document.addEventListener('scroll', spy, { passive: true }); spy();
|
|
|
|
const chapters = [...document.querySelectorAll('main h1[id]')];
|
|
const pager = document.getElementById('pager');
|
|
if (chapters.length > 1) {
|
|
// Multi-chapter pages are not used; the pager stays empty for now.
|
|
}
|
|
</script>
|
|
</body>
|
|
</html>
|