Extract HTML template into separate views file

This commit is contained in:
2026-05-29 14:18:59 +08:00
parent f9e323f70a
commit cf2d5fc77b
15 changed files with 862 additions and 233 deletions
+104 -59
View File
@@ -23,29 +23,17 @@
--sidebar-width: 300px;
--toolbar-height: 68px;
--transition: 180ms ease;
--font-sans: "Inter", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
--font-sans: "Avenir Next", "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);
--body-bg:
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%);
--brand-mark-bg: linear-gradient(135deg, var(--brand), #7c3aed);
--active-file-bg: linear-gradient(180deg, rgba(58,111,247,0.12), rgba(58,111,247,0.08));
--active-file-border: rgba(58,111,247,0.18);
--active-file-shadow: 0 8px 18px rgba(58,111,247,0.08);
--loading-bar-bg: linear-gradient(90deg, var(--brand), #38bdf8);
}
*, *::before, *::after { box-sizing: border-box; }
@@ -53,18 +41,9 @@ 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%);
background: var(--body-bg);
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); }
@@ -80,10 +59,10 @@ a:hover { color: var(--brand-strong); }
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);
border-right: 0;
background: var(--bg);
backdrop-filter: none;
box-shadow: none;
}
.sidebar.collapsed { margin-left: calc(-1 * var(--sidebar-width)); }
.sidebar-header { display: grid; gap: 14px; padding-bottom: 14px; }
@@ -96,7 +75,7 @@ a:hover { color: var(--brand-strong); }
.sidebar-brand-mark {
width: 36px; height: 36px; border-radius: 12px;
display: grid; place-items: center;
background: linear-gradient(135deg, var(--brand), #7c3aed);
background: var(--brand-mark-bg);
color: #fff; font-weight: 700; box-shadow: var(--shadow-sm);
}
.sidebar-brand-text { display: grid; line-height: 1.15; }
@@ -157,9 +136,9 @@ a:hover { color: var(--brand-strong); }
}
.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);
background: var(--active-file-bg);
border-color: var(--active-file-border);
box-shadow: var(--active-file-shadow);
}
.nav-file-icon {
width: 9px;
@@ -184,8 +163,9 @@ a:hover { color: var(--brand-strong); }
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);
background: var(--bg-elevated);
border-bottom: 0;
backdrop-filter: none;
}
.toolbar-breadcrumb { display: flex; align-items: center; gap: 10px; min-width: 0; }
.toolbar-kicker {
@@ -196,6 +176,32 @@ a:hover { color: var(--brand-strong); }
.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; }
.theme-select-wrap {
display: inline-flex;
align-items: center;
gap: 10px;
padding: 0 12px;
height: 38px;
border: 1px solid var(--border);
border-radius: 12px;
background: var(--bg-panel);
box-shadow: var(--shadow-sm);
}
.theme-select-label {
font-size: 12px;
font-weight: 700;
letter-spacing: 0.04em;
color: var(--text-muted);
}
.theme-select {
border: 0;
background: transparent;
color: var(--text);
font: inherit;
min-width: 104px;
outline: none;
cursor: pointer;
}
.btn-icon {
width: 38px; height: 38px; border: 1px solid transparent;
border-radius: 12px; background: transparent; color: var(--text-muted);
@@ -203,7 +209,11 @@ a:hover { color: var(--brand-strong); }
}
.btn-icon:hover { background: var(--bg-soft); color: var(--text); border-color: var(--border); }
.content-body { flex: 1; overflow: auto; }
.content-body {
flex: 1;
overflow: auto;
background: var(--bg-elevated);
}
.empty-state {
display: grid; place-items: center; min-height: 100%;
padding: 32px;
@@ -219,27 +229,44 @@ a:hover { color: var(--brand-strong); }
.empty-card p { margin: 0; color: var(--text-muted); line-height: 1.7; }
.markdown-body {
width: min(880px, calc(100% - 48px));
width: min(1120px, calc(100% - 48px));
margin: 0 auto;
padding: 36px 0 72px;
}
.article-layout {
display: grid;
grid-template-columns: minmax(0, 1fr) 230px;
grid-template-columns: minmax(0, 1fr) 250px;
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);
padding: 10px 0 14px;
margin-bottom: 20px;
border: 0;
border-bottom: 1px solid var(--border);
border-radius: 0;
background: transparent;
box-shadow: none;
backdrop-filter: none;
}
.article-title {
margin: 0 0 12px; font-size: clamp(30px, 4vw, 44px); line-height: 1.08;
margin: 0;
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-meta-side {
display: grid;
gap: 10px;
}
.article-meta-item {
display: inline-flex;
align-items: center;
gap: 6px;
padding: 0;
border-radius: 0;
background: transparent;
}
.article-body {
font-size: 16px; line-height: 1.85; color: var(--text);
}
@@ -291,7 +318,12 @@ a:hover { color: var(--brand-strong); }
.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-panel {
display: grid;
gap: 14px;
position: sticky;
top: 18px;
}
.toc-card {
padding: 16px 14px;
border: 1px solid var(--border);
@@ -300,6 +332,9 @@ a:hover { color: var(--brand-strong); }
box-shadow: var(--shadow-sm);
backdrop-filter: blur(18px);
}
.meta-card {
padding-bottom: 14px;
}
.toc-title {
font-size: 12px;
font-weight: 700;
@@ -316,11 +351,16 @@ a:hover { color: var(--brand-strong); }
display: flex;
align-items: center;
gap: 10px;
width: 100%;
padding: 8px 10px;
border: 0;
border-radius: 12px;
background: transparent;
color: var(--text-muted);
font-size: 13px;
text-align: left;
line-height: 1.35;
cursor: pointer;
}
.toc-link:hover {
background: var(--bg-soft);
@@ -344,7 +384,7 @@ a:hover { color: var(--brand-strong); }
.loading-bar {
position: fixed; top: 0; left: 0; height: 3px; width: 0;
background: linear-gradient(90deg, var(--brand), #38bdf8);
background: var(--loading-bar-bg);
z-index: 1000; pointer-events: none; transition: width 0.25s ease, opacity 0.2s ease;
}
.loading-bar.visible { width: 55%; }
@@ -371,10 +411,12 @@ a:hover { color: var(--brand-strong); }
.sidebar.collapsed { margin-left: 0; }
.content-toolbar { padding-left: 18px; }
.toolbar-breadcrumb { min-width: 0; }
.theme-select-wrap { max-width: 150px; }
.theme-select { min-width: 0; width: 100%; }
.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; }
.article-header { padding: 8px 0 12px; }
.mobile-nav-btn {
display: grid; place-items: center; position: fixed; right: 18px; bottom: 18px;
width: 52px; height: 52px; border-radius: 18px;
@@ -384,6 +426,14 @@ a:hover { color: var(--brand-strong); }
}
}
@media (max-width: 640px) {
.theme-select-label { display: none; }
.theme-select-wrap {
width: 92px;
padding: 0 10px;
}
}
[data-doc-theme="toc"] .content {
background:
radial-gradient(circle at top right, rgba(58, 111, 247, 0.08), transparent 28%),
@@ -393,14 +443,9 @@ a:hover { color: var(--brand-strong); }
width: min(1180px, calc(100% - 48px));
}
[data-doc-theme="toc"] .article-layout {
grid-template-columns: minmax(0, 1fr) 240px;
grid-template-columns: minmax(0, 1fr) 250px;
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;