Add gitignore and initial project files

This commit is contained in:
2026-05-29 12:46:34 +08:00
commit f9e323f70a
20 changed files with 3216 additions and 0 deletions
+438
View File
@@ -0,0 +1,438 @@
(function () {
'use strict';
const DATA = window.__WEBOOK__;
const navTree = DATA.nav || [];
const defaultFile = DATA.defaultFile;
const initialContent = DATA.initialContent;
// === DOM Elements ===
const sidebarNav = document.getElementById('sidebarNav');
const searchInput = document.getElementById('searchInput');
const btnToggleSidebar = document.getElementById('btnToggleSidebar');
const btnToggleTheme = document.getElementById('btnToggleTheme');
const contentBody = document.getElementById('contentBody');
const emptyState = document.getElementById('emptyState');
const markdownContent = document.getElementById('markdownContent');
const articleTitle = document.getElementById('articleTitle');
const articleMeta = document.getElementById('articleMeta');
const articleBody = document.getElementById('articleBody');
const tocNav = document.getElementById('tocNav');
const tocPanel = document.getElementById('tocPanel');
const loadingBar = document.getElementById('loadingBar');
const sidebar = document.getElementById('sidebar');
const mobileNavBtn = document.getElementById('mobileNavBtn');
let currentFile = null;
// === Theme ===
function getTheme() {
return localStorage.getItem('webook-theme') || 'light';
}
function setTheme(theme) {
document.documentElement.setAttribute('data-theme', theme);
localStorage.setItem('webook-theme', theme);
btnToggleTheme.textContent = theme === 'dark' ? '☀︎' : '☾';
// Swap highlight theme
const hlLink = document.querySelector('.theme-highlight');
if (hlLink) {
hlLink.href = theme === 'dark'
? '/_webook/highlight-dark.css'
: '/_webook/highlight-light.css';
}
}
function toggleTheme() {
const current = getTheme();
setTheme(current === 'light' ? 'dark' : 'light');
}
// Initialize theme
setTheme(getTheme());
// === Sidebar Toggle ===
function getSidebarVisible() {
return localStorage.getItem('webook-sidebar') !== 'hidden';
}
function setSidebarVisible(visible) {
if (visible) {
sidebar.classList.remove('collapsed');
localStorage.setItem('webook-sidebar', 'visible');
btnToggleSidebar.textContent = '☰';
} else {
sidebar.classList.add('collapsed');
localStorage.setItem('webook-sidebar', 'hidden');
btnToggleSidebar.textContent = '☷';
}
}
function toggleSidebar() {
setSidebarVisible(sidebar.classList.contains('collapsed'));
}
// Initialize sidebar state
setSidebarVisible(getSidebarVisible());
// === Mobile Sidebar ===
let sidebarOverlay = null;
function createOverlay() {
if (sidebarOverlay) return;
sidebarOverlay = document.createElement('div');
sidebarOverlay.className = 'sidebar-overlay';
sidebarOverlay.addEventListener('click', hideMobileSidebar);
document.body.appendChild(sidebarOverlay);
}
function showMobileSidebar() {
createOverlay();
sidebar.classList.add('mobile-visible');
sidebar.classList.remove('collapsed');
sidebarOverlay.classList.add('visible');
}
function hideMobileSidebar() {
sidebar.classList.remove('mobile-visible');
if (sidebarOverlay) {
sidebarOverlay.classList.remove('visible');
}
// Restore collapsed state if needed
if (!getSidebarVisible()) {
sidebar.classList.add('collapsed');
}
}
// === Navigation Rendering ===
function renderNavTree(items, level = 0) {
if (!items || items.length === 0) return '';
let html = '<ul class="nav-tree">';
for (const item of items) {
if (item.type === 'dir') {
html += `
<li class="nav-dir collapsed" data-path="${escapeHtml(item.path)}">
<div class="nav-dir-header" data-dir-path="${escapeHtml(item.path)}">
<span class="nav-dir-arrow">▾</span>
<span class="nav-dir-icon" aria-hidden="true"></span>
<span class="nav-dir-name">${escapeHtml(item.name)}</span>
</div>
<div class="nav-dir-children">
${renderNavTree(item.children, level + 1)}
</div>
</li>`;
} else {
const isActive = item.path === defaultFile;
html += `
<li class="nav-file${isActive ? ' active' : ''}" data-file-path="${escapeHtml(item.path)}">
<span class="nav-file-icon" aria-hidden="true"></span>
<span class="nav-file-name">${escapeHtml(item.meta ? item.meta.title : item.name)}</span>
</li>`;
}
}
html += '</ul>';
return html;
}
function escapeHtml(str) {
const div = document.createElement('div');
div.textContent = str;
return div.innerHTML;
}
// Render nav
sidebarNav.innerHTML = renderNavTree(navTree);
// === Navigation Events ===
sidebarNav.addEventListener('click', function (e) {
// Directory toggle
const dirHeader = e.target.closest('.nav-dir-header');
if (dirHeader) {
const dirItem = dirHeader.parentElement;
dirItem.classList.toggle('collapsed');
return;
}
// File click
const fileItem = e.target.closest('.nav-file');
if (fileItem) {
const filePath = fileItem.getAttribute('data-file-path');
loadFile(filePath);
setActiveFile(fileItem);
// On mobile, hide sidebar after selection
if (window.innerWidth <= 768) {
hideMobileSidebar();
}
}
});
function setActiveFile(fileItem) {
const prev = sidebarNav.querySelector('.nav-file.active');
if (prev) prev.classList.remove('active');
if (fileItem) fileItem.classList.add('active');
}
// === Search ===
searchInput.addEventListener('input', function () {
const query = this.value.trim().toLowerCase();
if (!query) {
// Show all
sidebarNav.querySelectorAll('.nav-hidden').forEach(el => el.classList.remove('nav-hidden'));
removeEmptyMessage();
return;
}
let hasVisible = false;
// Process directories
const dirs = sidebarNav.querySelectorAll('.nav-dir');
dirs.forEach(dir => {
let dirHasVisible = false;
const files = dir.querySelectorAll('.nav-file');
files.forEach(file => {
const name = file.querySelector('.nav-file-name').textContent.toLowerCase();
if (name.includes(query)) {
file.classList.remove('nav-hidden');
dirHasVisible = true;
} else {
file.classList.add('nav-hidden');
}
});
// Show/hide directory
if (dirHasVisible) {
dir.classList.remove('nav-hidden', 'collapsed');
hasVisible = true;
} else {
dir.classList.add('nav-hidden');
}
});
// Root-level files
const rootFiles = sidebarNav.querySelectorAll(':scope > .nav-tree > .nav-file');
rootFiles.forEach(file => {
const name = file.querySelector('.nav-file-name').textContent.toLowerCase();
if (name.includes(query)) {
file.classList.remove('nav-hidden');
hasVisible = true;
} else {
file.classList.add('nav-hidden');
}
});
if (!hasVisible) {
showEmptyMessage('未找到匹配的文件');
} else {
removeEmptyMessage();
}
});
function showEmptyMessage(msg) {
removeEmptyMessage();
const div = document.createElement('div');
div.className = 'nav-empty';
div.id = 'navEmptyMsg';
div.textContent = msg;
sidebarNav.appendChild(div);
}
function removeEmptyMessage() {
const existing = document.getElementById('navEmptyMsg');
if (existing) existing.remove();
}
// === File Loading ===
async function loadFile(filePath) {
if (currentFile === filePath) return;
currentFile = filePath;
showLoading();
try {
const resp = await fetch('/api/file?path=' + encodeURIComponent(filePath));
const json = await resp.json();
if (!json.success) {
throw new Error(json.error || 'Failed to load file');
}
const data = json.data;
// Update content
emptyState.style.display = 'none';
markdownContent.style.display = '';
articleTitle.textContent = data.title;
articleBody.innerHTML = data.html;
buildTOC();
// Update meta
const created = formatDate(data.meta.created);
const modified = formatDate(data.meta.modified);
const wordCount = data.meta.wordCount;
articleMeta.innerHTML = `
<span class="article-meta-item">📅 创建: ${created}</span>
<span class="article-meta-item">✏️ 修改: ${modified}</span>
<span class="article-meta-item">📝 字数: ${wordCount.toLocaleString()}</span>
`;
// Scroll to top
contentBody.scrollTop = 0;
// Update URL hash
if (history.pushState) {
history.pushState(null, '', '#' + encodeURIComponent(filePath));
}
// Apply syntax highlighting to code blocks in content
applyHighlighting();
} catch (err) {
emptyState.style.display = 'flex';
emptyState.querySelector('p').textContent = '加载失败: ' + err.message;
markdownContent.style.display = 'none';
} finally {
hideLoading();
}
}
function showLoading() {
loadingBar.classList.add('visible');
loadingBar.classList.remove('done');
}
function hideLoading() {
loadingBar.classList.add('done');
setTimeout(() => {
loadingBar.classList.remove('visible', 'done');
}, 350);
}
function formatDate(isoStr) {
if (!isoStr) return '-';
const d = new Date(isoStr);
const y = d.getFullYear();
const m = String(d.getMonth() + 1).padStart(2, '0');
const day = String(d.getDate()).padStart(2, '0');
const h = String(d.getHours()).padStart(2, '0');
const min = String(d.getMinutes()).padStart(2, '0');
return `${y}-${m}-${day} ${h}:${min}`;
}
function applyHighlighting() {
// highlight.js is loaded via CDN or bundled, but we handle it server-side.
// If any code blocks need client-side highlighting, do it here.
// For now, server-side rendering handles highlighting.
}
function slugifyHeading(text, index) {
return 'toc-' + text
.toLowerCase()
.replace(/['"`]/g, '')
.replace(/[^a-z0-9\u4e00-\u9fff]+/g, '-')
.replace(/^-+|-+$/g, '') + '-' + index;
}
function buildTOC() {
if (!tocNav || !tocPanel) return;
const headings = articleBody.querySelectorAll('h2, h3, h4');
if (!headings.length) {
tocPanel.classList.add('toc-empty');
tocNav.innerHTML = '<div class="toc-empty-state">当前页面没有可用目录</div>';
return;
}
tocPanel.classList.remove('toc-empty');
const items = [];
headings.forEach((heading, index) => {
const level = Number(heading.tagName.slice(1));
if (!heading.id) {
heading.id = slugifyHeading(heading.textContent || 'section', index);
}
items.push({
id: heading.id,
text: heading.textContent.trim(),
level
});
});
tocNav.innerHTML = items.map((item) => `
<a class="toc-link toc-level-${item.level}" href="#${escapeHtml(item.id)}" data-target="${escapeHtml(item.id)}">
<span class="toc-bullet"></span>
<span class="toc-text">${escapeHtml(item.text)}</span>
</a>
`).join('');
}
// === Initial Load ===
if (initialContent) {
emptyState.style.display = 'none';
markdownContent.style.display = '';
articleTitle.textContent = initialContent.title;
articleBody.innerHTML = initialContent.html;
buildTOC();
const created = formatDate(initialContent.meta.created);
const modified = formatDate(initialContent.meta.modified);
const wordCount = initialContent.meta.wordCount;
articleMeta.innerHTML = `
<span class="article-meta-item">📅 创建: ${created}</span>
<span class="article-meta-item">✏️ 修改: ${modified}</span>
<span class="article-meta-item">📝 字数: ${wordCount.toLocaleString()}</span>
`;
currentFile = defaultFile;
if (defaultFile && history.replaceState) {
history.replaceState(null, '', '#' + encodeURIComponent(defaultFile));
}
}
// === Hash-based navigation ===
function handleHashChange() {
const hash = decodeURIComponent(window.location.hash.slice(1));
if (hash && hash !== currentFile) {
loadFile(hash);
// Find and activate the nav item
const fileItem = sidebarNav.querySelector(`[data-file-path="${CSS.escape(hash)}"]`);
if (fileItem) {
setActiveFile(fileItem);
}
}
}
window.addEventListener('hashchange', handleHashChange);
// === Event Listeners ===
btnToggleTheme.addEventListener('click', toggleTheme);
btnToggleSidebar.addEventListener('click', toggleSidebar);
mobileNavBtn.addEventListener('click', showMobileSidebar);
// === Keyboard Shortcuts ===
document.addEventListener('keydown', function (e) {
// Ctrl+K or Cmd+K: focus search
if ((e.ctrlKey || e.metaKey) && e.key === 'k') {
e.preventDefault();
searchInput.focus();
searchInput.select();
}
// Escape: clear search
if (e.key === 'Escape' && document.activeElement === searchInput) {
searchInput.value = '';
searchInput.dispatchEvent(new Event('input'));
searchInput.blur();
}
});
// Close mobile sidebar on Escape
document.addEventListener('keydown', function (e) {
if (e.key === 'Escape' && sidebar.classList.contains('mobile-visible')) {
hideMobileSidebar();
}
});
})();
+39
View File
@@ -0,0 +1,39 @@
/* Dark theme for highlight.js - GitHub Dark-like */
.hljs { display: block; overflow-x: auto; padding: 0; background: transparent; color: #c9d1d9; }
.hljs-comment,
.hljs-quote { color: #8b949e; font-style: italic; }
.hljs-keyword,
.hljs-selector-tag,
.hljs-subst { color: #ff7b72; font-weight: bold; }
.hljs-number,
.hljs-literal,
.hljs-variable,
.hljs-template-variable,
.hljs-tag .hljs-attr { color: #79c0ff; }
.hljs-string,
.hljs-doctag { color: #a5d6ff; }
.hljs-title,
.hljs-section,
.hljs-selector-id { color: #d2a8ff; font-weight: bold; }
.hljs-subst { font-weight: normal; }
.hljs-type,
.hljs-class .hljs-title { color: #d2a8ff; font-weight: bold; }
.hljs-tag,
.hljs-name,
.hljs-attribute { color: #7ee787; font-weight: normal; }
.hljs-regexp,
.hljs-link { color: #a5d6ff; }
.hljs-symbol,
.hljs-bullet { color: #ffa657; }
.hljs-built_in,
.hljs-builtin-name { color: #79c0ff; }
.hljs-meta { color: #8b949e; font-weight: bold; }
.hljs-deletion { background: #490202; }
.hljs-addition { background: #04260f; }
.hljs-emphasis { font-style: italic; }
.hljs-strong { font-weight: bold; }
/* Line numbers */
.hljs-ln { border-collapse: collapse; }
.hljs-ln td { padding: 0; }
.hljs-ln-n { text-align: right; padding-right: 8px; color: #484f58; user-select: none; }
+39
View File
@@ -0,0 +1,39 @@
/* Light theme for highlight.js - GitHub-like */
.hljs { display: block; overflow-x: auto; padding: 0; background: transparent; color: #24292e; }
.hljs-comment,
.hljs-quote { color: #6a737d; font-style: italic; }
.hljs-keyword,
.hljs-selector-tag,
.hljs-subst { color: #d73a49; font-weight: bold; }
.hljs-number,
.hljs-literal,
.hljs-variable,
.hljs-template-variable,
.hljs-tag .hljs-attr { color: #005cc5; }
.hljs-string,
.hljs-doctag { color: #032f62; }
.hljs-title,
.hljs-section,
.hljs-selector-id { color: #6f42c1; font-weight: bold; }
.hljs-subst { font-weight: normal; }
.hljs-type,
.hljs-class .hljs-title { color: #6f42c1; font-weight: bold; }
.hljs-tag,
.hljs-name,
.hljs-attribute { color: #22863a; font-weight: normal; }
.hljs-regexp,
.hljs-link { color: #032f62; }
.hljs-symbol,
.hljs-bullet { color: #e36209; }
.hljs-built_in,
.hljs-builtin-name { color: #005cc5; }
.hljs-meta { color: #6a737d; font-weight: bold; }
.hljs-deletion { background: #ffeef0; }
.hljs-addition { background: #f0fff4; }
.hljs-emphasis { font-style: italic; }
.hljs-strong { font-weight: bold; }
/* Line numbers */
.hljs-ln { border-collapse: collapse; }
.hljs-ln td { padding: 0; }
.hljs-ln-n { text-align: right; padding-right: 8px; color: #959da5; user-select: none; }
+77
View File
@@ -0,0 +1,77 @@
(function() {
'use strict';
let socket;
let reconnectTimer;
let reconnectDelay = 1000;
function connect() {
const protocol = location.protocol === 'https:' ? 'wss:' : 'ws:';
const wsUrl = protocol + '//' + location.host + '/_ws';
try {
socket = new WebSocket(wsUrl);
socket.onopen = function() {
console.log('[webook] Live reload connected');
reconnectDelay = 1000;
};
socket.onmessage = function(event) {
try {
const msg = JSON.parse(event.data);
if (msg.type === 'reload') {
console.log('[webook] File changed, reloading...');
// If a markdown file changed and we're currently viewing it, reload via API
if (msg.file && /\.(md|markdown)$/i.test(msg.file)) {
const currentFile = getCurrentFile();
if (currentFile) {
reloadCurrentFile();
}
} else {
// For CSS/js/images, do a full reload
location.reload();
}
}
} catch (e) {
location.reload();
}
};
socket.onclose = function() {
console.log('[webook] Live reload disconnected');
scheduleReconnect();
};
socket.onerror = function() {
socket.close();
};
} catch (e) {
scheduleReconnect();
}
}
function scheduleReconnect() {
clearTimeout(reconnectTimer);
reconnectTimer = setTimeout(function() {
reconnectDelay = Math.min(reconnectDelay * 1.5, 30000);
connect();
}, reconnectDelay);
}
function getCurrentFile() {
const hash = decodeURIComponent(location.hash.slice(1));
if (hash) return hash;
return window.__WEBOOK__ ? window.__WEBOOK__.defaultFile : null;
}
function reloadCurrentFile() {
const hash = decodeURIComponent(location.hash.slice(1));
if (!hash) return location.reload();
// Dispatch hashchange to trigger reload
window.dispatchEvent(new HashChangeEvent('hashchange'));
}
connect();
})();
+411
View File
@@ -0,0 +1,411 @@
:root {
--bg: #f6f7fb;
--bg-elevated: rgba(255, 255, 255, 0.86);
--bg-panel: #ffffff;
--bg-soft: #eef2f7;
--bg-hover: #e8eef7;
--text: #1f2937;
--text-muted: #6b7280;
--text-soft: #94a3b8;
--border: rgba(148, 163, 184, 0.22);
--border-strong: rgba(148, 163, 184, 0.35);
--brand: #3a6ff7;
--brand-strong: #2757d6;
--brand-soft: rgba(58, 111, 247, 0.12);
--code-bg: #0f172a;
--code-fg: #e5edf9;
--shadow-lg: 0 20px 50px rgba(15, 23, 42, 0.08);
--shadow-md: 0 10px 28px rgba(15, 23, 42, 0.08);
--shadow-sm: 0 4px 16px rgba(15, 23, 42, 0.06);
--radius-lg: 20px;
--radius-md: 14px;
--radius-sm: 10px;
--sidebar-width: 300px;
--toolbar-height: 68px;
--transition: 180ms ease;
--font-sans: "Inter", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
--font-mono: "SFMono-Regular", "SF Mono", "JetBrains Mono", "Menlo", monospace;
}
[data-theme="dark"] {
--bg: #0b1120;
--bg-elevated: rgba(15, 23, 42, 0.82);
--bg-panel: #0f172a;
--bg-soft: #111827;
--bg-hover: #182033;
--text: #e5edf9;
--text-muted: #a3b2c6;
--text-soft: #6f8099;
--border: rgba(148, 163, 184, 0.16);
--border-strong: rgba(148, 163, 184, 0.26);
--brand: #7aa2ff;
--brand-strong: #93b4ff;
--brand-soft: rgba(122, 162, 255, 0.14);
--code-bg: #020617;
--code-fg: #dbeafe;
--shadow-lg: 0 24px 60px rgba(2, 6, 23, 0.34);
--shadow-md: 0 14px 32px rgba(2, 6, 23, 0.28);
--shadow-sm: 0 6px 18px rgba(2, 6, 23, 0.2);
}
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
font-family: var(--font-sans);
color: var(--text);
background:
radial-gradient(circle at top left, rgba(58, 111, 247, 0.12), transparent 30%),
radial-gradient(circle at top right, rgba(56, 189, 248, 0.10), transparent 26%),
linear-gradient(180deg, #fbfcff 0%, var(--bg) 100%);
overflow: hidden;
}
[data-theme="dark"] body {
background:
radial-gradient(circle at top left, rgba(58, 111, 247, 0.16), transparent 30%),
radial-gradient(circle at top right, rgba(56, 189, 248, 0.10), transparent 26%),
linear-gradient(180deg, #0b1120 0%, #09101c 100%);
}
a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-strong); }
.app {
display: grid;
grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
height: 100vh;
}
.sidebar {
display: flex;
flex-direction: column;
min-width: 0;
min-height: 0;
padding: 18px 14px 18px 18px;
border-right: 1px solid var(--border);
background: var(--bg-elevated);
backdrop-filter: blur(18px);
box-shadow: inset -1px 0 0 rgba(255,255,255,0.3);
}
.sidebar.collapsed { margin-left: calc(-1 * var(--sidebar-width)); }
.sidebar-header { display: grid; gap: 14px; padding-bottom: 14px; }
.sidebar-brand {
display: flex; align-items: center; gap: 12px;
color: var(--text);
padding: 10px 12px; border-radius: var(--radius-md);
}
.sidebar-brand:hover { background: var(--bg-soft); }
.sidebar-brand-mark {
width: 36px; height: 36px; border-radius: 12px;
display: grid; place-items: center;
background: linear-gradient(135deg, var(--brand), #7c3aed);
color: #fff; font-weight: 700; box-shadow: var(--shadow-sm);
}
.sidebar-brand-text { display: grid; line-height: 1.15; }
.sidebar-brand-text strong { font-size: 15px; }
.sidebar-brand-text small { color: var(--text-muted); font-size: 12px; }
.search-box input {
width: 100%; border: 1px solid var(--border);
border-radius: 999px; padding: 11px 14px;
background: var(--bg-panel); color: var(--text);
outline: none; box-shadow: var(--shadow-sm);
}
.search-box input:focus { border-color: var(--brand); box-shadow: 0 0 0 4px var(--brand-soft); }
.search-box input::placeholder { color: var(--text-soft); }
.sidebar-nav { flex: 1; overflow: auto; padding: 4px 2px 0 0; }
.nav-tree { list-style: none; margin: 0; padding: 0; }
.nav-tree ul { list-style: none; margin: 0; padding: 0; }
.nav-dir { margin-bottom: 4px; }
.nav-dir-header {
display: flex; align-items: center; gap: 8px;
padding: 10px 12px; border-radius: 12px;
color: var(--text-muted); font-size: 13px; font-weight: 600;
cursor: pointer; user-select: none;
}
.nav-dir-header:hover { background: var(--bg-soft); color: var(--text); }
.nav-dir-arrow { width: 14px; text-align: center; transition: transform var(--transition); color: var(--text-soft); }
.nav-dir.collapsed .nav-dir-arrow { transform: rotate(-90deg); }
.nav-dir-icon {
width: 12px;
height: 12px;
border-radius: 4px;
border: 1.5px solid currentColor;
position: relative;
flex: 0 0 auto;
opacity: 0.75;
}
.nav-dir-icon::after {
content: '';
position: absolute;
right: -1px;
top: -1px;
width: 4px;
height: 4px;
border-top: 1.5px solid currentColor;
border-right: 1.5px solid currentColor;
border-radius: 0 4px 0 0;
transform: skew(12deg);
}
.nav-dir-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-dir-children { overflow: hidden; padding-left: 10px; }
.nav-dir.collapsed .nav-dir-children { max-height: 0 !important; }
.nav-file {
display: flex; align-items: center; gap: 10px;
margin: 2px 0; padding: 10px 12px 10px 28px;
border-radius: 12px; color: var(--text);
cursor: pointer; border: 1px solid transparent;
}
.nav-file:hover { background: var(--bg-soft); }
.nav-file.active {
background: linear-gradient(180deg, rgba(58,111,247,0.12), rgba(58,111,247,0.08));
border-color: rgba(58,111,247,0.18);
box-shadow: 0 8px 18px rgba(58,111,247,0.08);
}
.nav-file-icon {
width: 9px;
height: 9px;
border-radius: 50%;
background: currentColor;
opacity: 0.45;
flex: 0 0 auto;
}
.nav-file-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.nav-hidden { display: none !important; }
.nav-empty {
margin: 14px 10px; padding: 18px 14px; border-radius: 16px;
background: var(--bg-soft); color: var(--text-muted); text-align: center;
}
.content {
min-width: 0; display: flex; flex-direction: column;
height: 100vh; overflow: hidden;
}
.content-toolbar {
height: var(--toolbar-height);
display: flex; align-items: center; justify-content: space-between;
gap: 16px; padding: 0 18px 0 22px;
background: var(--bg-elevated); border-bottom: 1px solid var(--border);
backdrop-filter: blur(18px);
}
.toolbar-breadcrumb { display: flex; align-items: center; gap: 10px; min-width: 0; }
.toolbar-kicker {
display: inline-flex; align-items: center;
padding: 5px 10px; border-radius: 999px;
background: var(--brand-soft); color: var(--brand); font-size: 12px; font-weight: 700;
}
.toolbar-divider, .toolbar-title { color: var(--text-muted); font-size: 14px; }
.toolbar-title { color: var(--text); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.toolbar-actions { display: flex; align-items: center; gap: 8px; }
.btn-icon {
width: 38px; height: 38px; border: 1px solid transparent;
border-radius: 12px; background: transparent; color: var(--text-muted);
cursor: pointer; display: grid; place-items: center; font-size: 16px;
}
.btn-icon:hover { background: var(--bg-soft); color: var(--text); border-color: var(--border); }
.content-body { flex: 1; overflow: auto; }
.empty-state {
display: grid; place-items: center; min-height: 100%;
padding: 32px;
}
.empty-card {
max-width: 420px; width: 100%;
padding: 32px; border-radius: 24px;
background: var(--bg-elevated); border: 1px solid var(--border);
box-shadow: var(--shadow-lg); text-align: center; backdrop-filter: blur(18px);
}
.empty-icon { font-size: 48px; margin-bottom: 16px; }
.empty-card h2 { margin: 0 0 8px; font-size: 22px; }
.empty-card p { margin: 0; color: var(--text-muted); line-height: 1.7; }
.markdown-body {
width: min(880px, calc(100% - 48px));
margin: 0 auto;
padding: 36px 0 72px;
}
.article-layout {
display: grid;
grid-template-columns: minmax(0, 1fr) 230px;
gap: 24px;
align-items: start;
}
.article-header {
padding: 22px 24px; margin-bottom: 24px;
border: 1px solid var(--border); border-radius: 24px;
background: var(--bg-elevated); box-shadow: var(--shadow-md); backdrop-filter: blur(18px);
}
.article-title {
margin: 0 0 12px; font-size: clamp(30px, 4vw, 44px); line-height: 1.08;
letter-spacing: -0.03em; color: var(--text);
}
.article-meta { display: flex; flex-wrap: wrap; gap: 10px 16px; color: var(--text-muted); font-size: 13px; }
.article-meta-item { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 999px; background: var(--bg-soft); }
.article-body {
font-size: 16px; line-height: 1.85; color: var(--text);
}
.article-body > :first-child { margin-top: 0; }
.article-body h1, .article-body h2, .article-body h3, .article-body h4 {
letter-spacing: -0.02em; line-height: 1.25; scroll-margin-top: 96px;
}
.article-body h1 { font-size: 2rem; margin: 1.5em 0 0.6em; }
.article-body h2 {
font-size: 1.5rem; margin: 1.8em 0 0.8em; padding-bottom: 10px;
border-bottom: 1px solid var(--border);
}
.article-body h3 { font-size: 1.15rem; margin: 1.4em 0 0.65em; }
.article-body h4, .article-body h5, .article-body h6 { font-size: 1rem; margin: 1.2em 0 0.6em; }
.article-body p { margin: 0.85em 0; color: var(--text); }
.article-body a { text-decoration: underline; text-decoration-color: rgba(58,111,247,0.28); text-underline-offset: 2px; }
.article-body ul, .article-body ol { padding-left: 1.5em; margin: 0.9em 0; }
.article-body li { margin: 0.35em 0; }
.article-body blockquote {
margin: 1.2em 0; padding: 14px 18px;
border-left: 4px solid var(--brand); border-radius: 0 16px 16px 0;
background: var(--bg-soft); color: var(--text-muted);
}
.article-body code {
font-family: var(--font-mono); font-size: 0.92em;
padding: 0.18em 0.42em; border-radius: 8px;
background: rgba(148, 163, 184, 0.14); color: var(--text);
}
.article-body pre {
margin: 1.2em 0; padding: 18px 20px;
border-radius: 20px; overflow: auto;
background: var(--code-bg) !important; color: var(--code-fg);
border: 1px solid rgba(148, 163, 184, 0.12);
box-shadow: var(--shadow-md);
}
.article-body pre code {
padding: 0; background: transparent; color: inherit; font-size: 0.92rem;
}
.article-body table {
width: 100%; margin: 1.2em 0; border-collapse: collapse;
overflow: hidden; border-radius: 16px; border: 1px solid var(--border);
}
.article-body th, .article-body td {
padding: 11px 14px; border-bottom: 1px solid var(--border); text-align: left;
}
.article-body th { background: var(--bg-soft); font-weight: 700; }
.article-body tr:last-child td { border-bottom: 0; }
.article-body img { max-width: 100%; height: auto; border-radius: 18px; box-shadow: var(--shadow-sm); }
.article-body hr { margin: 2em 0; border: 0; border-top: 1px solid var(--border); }
.article-body input[type="checkbox"] { margin-right: 8px; }
.toc-panel { display: none; position: sticky; top: 18px; }
.toc-card {
padding: 16px 14px;
border: 1px solid var(--border);
border-radius: 20px;
background: var(--bg-elevated);
box-shadow: var(--shadow-sm);
backdrop-filter: blur(18px);
}
.toc-title {
font-size: 12px;
font-weight: 700;
letter-spacing: 0.08em;
text-transform: uppercase;
color: var(--text-muted);
margin-bottom: 12px;
}
.toc-nav {
display: grid;
gap: 4px;
}
.toc-link {
display: flex;
align-items: center;
gap: 10px;
padding: 8px 10px;
border-radius: 12px;
color: var(--text-muted);
font-size: 13px;
line-height: 1.35;
}
.toc-link:hover {
background: var(--bg-soft);
color: var(--text);
}
.toc-link.toc-level-3 { padding-left: 20px; font-size: 12.5px; }
.toc-link.toc-level-4 { padding-left: 30px; font-size: 12px; }
.toc-bullet {
width: 6px;
height: 6px;
border-radius: 50%;
background: currentColor;
opacity: 0.35;
flex: 0 0 auto;
}
.toc-empty-state {
color: var(--text-muted);
font-size: 13px;
padding: 6px 2px 2px;
}
.loading-bar {
position: fixed; top: 0; left: 0; height: 3px; width: 0;
background: linear-gradient(90deg, var(--brand), #38bdf8);
z-index: 1000; pointer-events: none; transition: width 0.25s ease, opacity 0.2s ease;
}
.loading-bar.visible { width: 55%; }
.loading-bar.done { width: 100%; opacity: 0; }
.mobile-nav-btn { display: none; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
background: rgba(148, 163, 184, 0.35); border-radius: 999px; border: 2px solid transparent; background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover { background: rgba(148, 163, 184, 0.5); background-clip: content-box; }
@media (max-width: 900px) {
.app { grid-template-columns: 1fr; }
.sidebar {
position: fixed; inset: 0 auto 0 0; z-index: 220;
width: min(86vw, 320px); transform: translateX(-100%);
transition: transform 220ms ease;
box-shadow: var(--shadow-lg);
}
.sidebar.mobile-visible { transform: translateX(0); }
.sidebar.collapsed { margin-left: 0; }
.content-toolbar { padding-left: 18px; }
.toolbar-breadcrumb { min-width: 0; }
.markdown-body { width: min(100%, calc(100% - 28px)); padding-top: 20px; padding-bottom: 72px; }
.article-layout { grid-template-columns: minmax(0, 1fr); }
.toc-panel { display: none !important; }
.article-header { padding: 20px; }
.mobile-nav-btn {
display: grid; place-items: center; position: fixed; right: 18px; bottom: 18px;
width: 52px; height: 52px; border-radius: 18px;
border: 1px solid var(--border); background: var(--bg-elevated);
color: var(--text); box-shadow: var(--shadow-lg); z-index: 210;
backdrop-filter: blur(18px);
}
}
[data-doc-theme="toc"] .content {
background:
radial-gradient(circle at top right, rgba(58, 111, 247, 0.08), transparent 28%),
transparent;
}
[data-doc-theme="toc"] .markdown-body {
width: min(1180px, calc(100% - 48px));
}
[data-doc-theme="toc"] .article-layout {
grid-template-columns: minmax(0, 1fr) 240px;
gap: 28px;
}
[data-doc-theme="toc"] .toc-panel { display: block; }
[data-doc-theme="toc"] .toc-card {
position: sticky;
top: 18px;
}
.sidebar-overlay {
display: none; position: fixed; inset: 0; z-index: 210;
background: rgba(2, 6, 23, 0.34); backdrop-filter: blur(4px);
}
@media (max-width: 900px) {
.sidebar-overlay.visible { display: block; }
}