jianzhihuixiang/alacarte-novel-website/chapters/chapter-3.html
小虾米 f8894dd3f3 fix: 修复上一章/下一章导航对小数章节(如107.5)的支持
- updateNavButtons: 改用数组索引查找,而非简单的+1/-1
- updateSidebarHighlight: 使用parseFloat比较章节ID
- updateMobileTOCHighlight: 使用parseFloat比较章节ID
- 更新版本号强制刷新缓存
2026-03-27 17:42:41 +08:00

631 lines
29 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>幽暗密林 - 阿拉德:剑之回响</title>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
<style>
:root {
--bg-primary: linear-gradient(135deg, #0f0c29 0%, #302b63 50%, #24243e 100%);
--text-primary: #e0e0e0;
--text-secondary: #888;
--accent-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
--border-color: rgba(255,255,255,0.1);
--btn-bg: rgba(255,255,255,0.1);
--btn-hover: rgba(255,255,255,0.2);
}
[data-theme="light"] {
--bg-primary: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
--text-primary: #333;
--text-secondary: #666;
--border-color: rgba(0,0,0,0.1);
--btn-bg: rgba(0,0,0,0.05);
--btn-hover: rgba(0,0,0,0.1);
}
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: 'Noto Serif SC', serif;
background: var(--bg-primary);
color: var(--text-primary);
line-height: 1.8;
min-height: 100vh;
transition: all 0.3s ease;
}
.container {
max-width: 800px;
margin: 0 auto;
padding: 20px;
padding-bottom: 120px;
}
/* 顶部导航 */
.top-nav {
position: fixed;
top: 0;
left: 0;
right: 0;
background: rgba(0,0,0,0.3);
backdrop-filter: blur(10px);
border-bottom: 1px solid var(--border-color);
z-index: 1000;
padding: 10px 20px;
}
.top-nav-content {
max-width: 800px;
margin: 0 auto;
display: flex;
justify-content: space-between;
align-items: center;
}
.nav-link {
color: var(--text-primary);
text-decoration: none;
font-family: 'Noto Sans SC', sans-serif;
font-size: 14px;
padding: 8px 16px;
background: var(--btn-bg);
border: 1px solid var(--border-color);
border-radius: 8px;
transition: all 0.3s ease;
}
.nav-link:hover {
background: var(--btn-hover);
}
.chapter-header {
text-align: center;
padding: 80px 0 40px;
border-bottom: 1px solid var(--border-color);
margin-bottom: 40px;
}
.chapter-number {
font-size: 14px;
color: var(--text-secondary);
letter-spacing: 4px;
text-transform: uppercase;
margin-bottom: 10px;
}
.chapter-title {
font-size: 32px;
font-weight: 700;
background: var(--accent-gradient);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
background-clip: text;
margin-bottom: 20px;
}
.chapter-meta {
font-size: 14px;
color: var(--text-secondary);
}
.chapter-content {
font-size: 18px;
line-height: 2;
text-align: justify;
}
.chapter-content p {
margin-bottom: 1.5em;
text-indent: 2em;
}
.chapter-content p:first-of-type::first-letter {
font-size: 3em;
float: left;
line-height: 1;
margin-right: 8px;
margin-top: -5px;
background: var(--accent-gradient);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
background-clip: text;
font-weight: 700;
}
/* 固定底部导航 */
.fixed-nav {
position: fixed;
bottom: 0;
left: 0;
right: 0;
background: rgba(0,0,0,0.3);
backdrop-filter: blur(10px);
border-top: 1px solid var(--border-color);
z-index: 1000;
padding: 15px 20px;
}
.fixed-nav-content {
max-width: 800px;
margin: 0 auto;
display: flex;
justify-content: space-between;
align-items: center;
}
.nav-btn {
padding: 12px 24px;
background: var(--btn-bg);
border: 1px solid var(--border-color);
border-radius: 8px;
color: var(--text-primary);
text-decoration: none;
transition: all 0.3s ease;
font-family: 'Noto Sans SC', sans-serif;
font-size: 14px;
cursor: pointer;
}
.nav-btn:hover {
background: var(--btn-hover);
transform: translateY(-2px);
}
.nav-btn.disabled {
opacity: 0.3;
cursor: not-allowed;
pointer-events: none;
}
/* 右侧滚动按钮 */
.scroll-buttons {
position: fixed;
right: 20px;
bottom: 90px;
display: flex;
flex-direction: column;
gap: 10px;
z-index: 1001;
}
.scroll-btn {
width: 40px;
height: 40px;
border-radius: 8px;
background: var(--btn-bg);
border: 1px solid var(--border-color);
color: var(--text-primary);
cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
font-size: 16px;
transition: all 0.3s ease;
font-family: 'Noto Sans SC', sans-serif;
}
.scroll-btn:hover {
background: var(--btn-hover);
}
/* 侧边栏 - 标题固定,内容滚动 */
.sidebar {
position: fixed;
right: 20px;
top: 50%;
transform: translateY(-50%);
background: rgba(0,0,0,0.5);
backdrop-filter: blur(10px);
border-radius: 12px;
border: 1px solid var(--border-color);
width: 200px;
max-height: 70vh;
z-index: 999;
display: flex;
flex-direction: column;
}
.sidebar-title {
font-size: 14px;
color: var(--text-secondary);
text-transform: uppercase;
letter-spacing: 2px;
padding: 15px 20px;
border-bottom: 1px solid var(--border-color);
flex-shrink: 0;
}
.sidebar-content {
overflow-y: auto;
padding: 10px 20px 20px;
flex: 1;
scrollbar-width: thin;
scrollbar-color: transparent transparent;
transition: scrollbar-color 0.3s ease;
}
.sidebar-content:hover {
scrollbar-color: rgba(255,255,255,0.3) transparent;
}
.sidebar-content::-webkit-scrollbar {
width: 6px;
}
.sidebar-content::-webkit-scrollbar-track {
background: transparent;
}
.sidebar-content::-webkit-scrollbar-thumb {
background: transparent;
border-radius: 3px;
transition: background 0.3s ease;
}
.sidebar-content:hover::-webkit-scrollbar-thumb {
background: rgba(255,255,255,0.3);
}
.sidebar-content:hover::-webkit-scrollbar-thumb:hover {
background: rgba(255,255,255,0.5);
}
[data-theme="light"] .sidebar-content:hover {
scrollbar-color: rgba(0,0,0,0.3) transparent;
}
[data-theme="light"] .sidebar-content:hover::-webkit-scrollbar-thumb {
background: rgba(0,0,0,0.3);
}
[data-theme="light"] .sidebar-content:hover::-webkit-scrollbar-thumb:hover {
background: rgba(0,0,0,0.5);
}
.sidebar-chapter {
display: block;
padding: 8px 0;
color: #aaa;
text-decoration: none;
font-size: 13px;
border-bottom: 1px solid rgba(255,255,255,0.05);
transition: all 0.3s ease;
line-height: 1.5;
}
.sidebar-chapter:hover {
color: #667eea;
}
.sidebar-chapter.current {
color: #667eea;
font-weight: 600;
}
@media (max-width: 1200px) {
.sidebar {
display: none;
}
}
@media (max-width: 600px) {
.chapter-title {
font-size: 24px;
}
.chapter-content {
font-size: 16px;
}
.fixed-nav-content {
gap: 10px;
}
.nav-btn {
padding: 10px 15px;
font-size: 12px;
}
.scroll-buttons {
right: 10px;
bottom: 80px;
}
.scroll-btn {
width: 36px;
height: 36px;
}
}
/* 滚动条样式 */
.sidebar::-webkit-scrollbar {
width: 4px;
}
.sidebar::-webkit-scrollbar-track {
background: transparent;
}
.sidebar::-webkit-scrollbar-thumb {
background: rgba(255,255,255,0.2);
border-radius: 2px;
}
</style>
</head>
<body>
<!-- 顶部导航 -->
<nav class="top-nav">
<div class="top-nav-content">
<a href="../index.html" class="nav-link">返回首页</a>
<button class="nav-link" id="themeToggle">切换主题</button>
</div>
</nav>
<div class="container">
<header class="chapter-header">
<div class="chapter-number">Chapter 3</div>
<h1 class="chapter-title">幽暗密林</h1>
</header>
<article class="chapter-content">
<p>清晨的训练比往常更加艰苦。</p>
<p>阿甘左让林克绕着艾尔文防线跑完了十圈,然后是五百次挥剑。当太阳完全升起时,林克已经累得抬不起手臂。</p>
<p>"今天的训练结束了。"阿甘左说,"但真正的考验才刚刚开始。"</p>
<p>林克喘着粗气,抬起头:"什么意思?"</p>
<p>"幽暗密林。"阿甘左转身看向北边的森林,"格兰之森的入口。从现在开始,你要去那里修炼。"</p>
<p>"幽暗密林……"林克喃喃自语。他听林纳斯提起过,那里是格兰之森的外围区域,栖息着一种叫做猫妖的怪物。</p>
<p>"有问题?"</p>
<p>"没有。"林克握紧新得的太刀,"什么时候出发?"</p>
<p>"现在。"</p>
<p>---</p>
<p>格兰之森位于艾尔文防线的北边,是一片广袤无垠的原始森林。相传数千年前,这里曾经是精灵族的领地,但如今只剩下茂密的树木和危险的怪物。</p>
<p>林克踏入森林的那一刻,立刻感受到了不同。</p>
<p>空气变得潮湿起来,带着一股腐败落叶的气味。阳光被树冠完全遮挡,林子里暗得像是黄昏。脚下的土地湿软泥泞,每走一步都会陷入半寸深的腐殖质。</p>
<p>"跟紧我。"阿甘左的声音从前面传来,"幽暗密林在格兰之森深处,离这里还有很远。"</p>
<p>林克应了一声,快步跟上。</p>
<p>一路上的怪物比洛兰多得多。哥布林自不必说,还有体型更大的牛头人、能够飞行的猫头鹰,以及一些叫不出名字的奇怪生物。但阿甘左似乎没有兴趣清理它们,只是带着林克绕开怪物密集的区域。</p>
<p>"为什么不打?"林克问。</p>
<p>"你的目标是幽暗密林。"阿甘左说,"路上这些杂碎不值得浪费时间。"</p>
<p>林克点点头,继续前行。</p>
<p>---</p>
<p>当他们到达幽暗密林时,太阳已经偏西。</p>
<p>入口是一片茂密的灌木丛,灌木丛后面是一条蜿蜒的小路。小路的两旁长满了高耸入云的古树,枝叶交织在一起,形成了一道绿色的穹顶。</p>
<p>"就是这里。"阿甘左停下脚步,"进去吧。"</p>
<p>林克看着那条幽暗的小路,心里突然涌起一种不安的感觉。</p>
<p>"师父……"</p>
<p>"叫我阿甘左。"男人打断他,"师父这个词太正式了,我不习惯。"</p>
<p>"好吧。"林克深吸一口气,"阿甘左,如果我出不来了……"</p>
<p>"不会有那种事。"阿甘左说,"但如果你死了,我会帮你收尸的。"</p>
<p>林克愣了一下,然后笑了。</p>
<p>"谢了。"</p>
<p>他迈步走进幽暗密林。</p>
<p>---</p>
<p>林子里的光线比外面更暗。</p>
<p>林克拔出太刀,警惕地看着四周。空气中弥漫着一股腥臭味,像是某种大型猫科动物的气味。</p>
<p>"喵——"</p>
<p>一声凄厉的猫叫从头顶传来。</p>
<p>林克猛然抬头,看到一只怪物从天而降。</p>
<p>那是一只猫妖。</p>
<p>它的体型比普通野猫大得多,身长接近一米五。浑身的皮毛是暗红色的,上面布满了黑色的斑纹。它的眼睛是黄色的,瞳孔呈竖线状,在黑暗中闪着幽光。它的爪子很长,像是五把锋利的短剑。</p>
<p>猫妖落地后立刻向林克扑来。</p>
<p>林克侧身躲过,太刀横扫,砍向猫妖的侧腹。</p>
<p>"当!"</p>
<p>金属碰撞的声音。猫妖的皮毛竟然硬得像皮革一样,太刀只在上面留下了一道白痕。</p>
<p>"皮这么厚?"林克咬牙,再次挥刀。</p>
<p>但猫妖的速度比他快得多。</p>
<p>不等林克第二刀砍出,猫妖已经绕到了他的身后。锋利的爪子划向他的后背。</p>
<p>"刺啦——"</p>
<p>皮甲被撕开,后背上多了三道血痕。</p>
<p>林克闷哼一声,转身挥刀。但猫妖已经跳开了。</p>
<p>"速度很快……"林克喘着气,盯着那只猫妖,"力量也不小。"</p>
<p>猫妖蹲在地上,黄色的眼睛盯着他,喉咙里发出低沉的咆哮。</p>
<p>林克深吸一口气,强迫自己冷静下来。</p>
<p>阿甘左说过:剑术的最高境界不是快,是准。</p>
<p>他仔细观察着猫妖的动作,等待机会。</p>
<p>---</p>
<p>猫妖再次扑上来。</p>
<p>这一次,林克没有躲。</p>
<p>他在猫妖扑到面前的瞬间猛然蹲下,太刀从下往上斜刺。</p>
<p>"噗嗤!"</p>
<p>刀刃刺入猫妖的腹部,鲜血喷涌而出。</p>
<p>猫妖发出刺耳的尖叫,疯狂地挣扎着。但林克死死抓住刀柄,不让它挣脱。</p>
<p>"去死!"</p>
<p>他用力一绞,然后猛然拔出太刀。</p>
<p>猫妖倒在地上,抽搐了几下,不再动了。</p>
<p>林克喘着粗气,看着地上的尸体。这是他第一次独自杀掉猫妖。</p>
<p>但还没等他来得及庆祝,四周传来窸窸窣窣的声音。</p>
<p>他转头看向四周,瞳孔猛然收缩。</p>
<p>至少有二十只猫妖从四面八方的灌木丛中钻出来,将他团团围住。</p>
<p>"该死……"林克握紧太刀,"这么多?"</p>
<p>---</p>
<p>猫妖群缓缓逼近。</p>
<p>林克背靠一棵大树,警惕地看着四周。每一只猫妖都在盯着他,黄色的眼睛在黑暗中像是鬼火一样。</p>
<p>不能再等了。</p>
<p>林克突然动了。</p>
<p>他冲向左侧最短的包围线,太刀挥出,斩向一只猫妖的脖子。</p>
<p>"噗!"</p>
<p>鲜血飞溅,那只猫妖的头颅滚落在地。</p>
<p>但这只是开始。</p>
<p>剩下的猫妖像是收到了什么信号,同时向林克扑来。</p>
<p>林克在它们之间穿梭,太刀每一次挥出都能带走一只猫妖的性命。但猫妖的数量太多了,他的身上不断增添新的伤口。</p>
<p>"滚开!"</p>
<p>他怒吼一声,太刀横扫,将扑在最前面的三只猫妖逼退。</p>
<p>但更多的猫妖又围上来。</p>
<p>林克感觉体力在快速流逝,动作越来越慢。伤口流出的血染红了他的皮甲,让他的动作变得迟钝。</p>
<p>"要死在这里了吗……"</p>
<p>他咬紧牙关,继续战斗。</p>
<p>---</p>
<p>就在林克快要支撑不住的时候,他突然听到了一声低沉的咆哮。</p>
<p>"吼——"</p>
<p>声音是从密林深处传来的,震得树叶簌簌落下。</p>
<p>猫妖群的动作顿了一下,然后像是收到了什么命令,同时后退,消失在灌木丛中。</p>
<p>林克愣了一下,看着突然空旷起来的四周。</p>
<p>"刚才那是……什么?"</p>
<p>他警惕地看着密林深处,总觉得刚才那声咆哮有些耳熟。</p>
<p>不,不是耳熟。</p>
<p>而是……共鸣。</p>
<p>他感觉体内的血液突然沸腾了一下,胸口处传来一阵灼热感。那是卡赞诅咒的位置。</p>
<p>自从三年前那场事故之后,卡赞诅咒就一直在他的体内蛰伏。但刚才,它似乎被什么东西唤醒了。</p>
<p>"发生了什么……"林克捂住胸口,感受着心脏剧烈跳动。</p>
<p>那种感觉很奇怪,既痛苦又畅快,像是有什么东西想要破土而出。</p>
<p>他站在原地,等待那股感觉过去。</p>
<p>当一切恢复正常时,天色已经完全暗下来了。</p>
<p>---</p>
<p>林克拖着伤痕累累的身体走出幽暗密林时,阿甘左还在原地等着他。</p>
<p>男人看着林克满身是血的样子,挑了挑眉。</p>
<p>"活着出来了?"</p>
<p>"差一点就出不来了。"林克苦笑。</p>
<p>阿甘左点点头:"走吧,先回去包扎伤口。"</p>
<p>"是。"</p>
<p>林克应了一声,正要跟上阿甘左,突然停住脚步。</p>
<p>"阿甘左。"</p>
<p>"什么事?"</p>
<p>"我在幽暗密林深处听到了一声咆哮。"林克说,"然后……我体内的卡赞诅咒好像产生了共鸣。"</p>
<p>阿甘左的脚步顿了一下。</p>
<p>"你说什么?"</p>
<p>"卡赞诅咒。"林克重复道,"刚才在幽暗密林里,它好像被什么东西唤醒了。"</p>
<p>阿甘左沉默了很久。</p>
<p>"这件事以后再说。"他说,"先回去。"</p>
<p>林克看着阿甘左的背影,心里涌起一种不安的感觉。</p>
<p>师父似乎知道什么。</p>
<p>---</p>
<p>回到艾尔文防线时,赛丽亚看到林克的样子吓了一跳。</p>
<p>"天哪!你怎么又受伤了?"</p>
<p>"训练。"林克坐在椅子上,虚弱地说。</p>
<p>赛丽亚赶紧拿来药水和小心地帮他处理伤口。她的动作很轻柔,像是生怕弄疼他。</p>
<p>"幽暗密林很危险吗?"赛丽亚问。</p>
<p>"还好。"林克说,"就是怪物比较多。"</p>
<p>"下次小心一点。"赛丽亚说,"你总是这样不顾自己的身体……"</p>
<p>她的语气中带着一丝责备,但更多的是关心。</p>
<p>林克看着她专注地帮自己包扎伤口的样子,心里涌起一种温暖的感觉。</p>
<p>"赛丽亚。"</p>
<p>"嗯?"</p>
<p>"你为什么对我这么好?"</p>
<p>赛丽亚的手顿了一下,然后继续包扎。</p>
<p>"因为你是我的客人呀。"她笑着说,"而且……我觉得你是个好人。"</p>
<p>林克没有再说什么,只是静静地看着她。</p>
<p>---</p>
<p>夜晚,林克躺在旅馆的床上,睁着眼睛看着天花板。</p>
<p>今天在幽暗密林深处听到的那声咆哮,始终在他脑海中回荡。</p>
<p>还有卡赞诅咒的共鸣。</p>
<p>那到底是什么?</p>
<p>他抬起手,看着自己的掌心。在月光下,他可以看到皮肤下隐约浮现的红色纹路——那是卡赞诅咒的印记。</p>
<p>三年前的那场事故,他几乎失去了所有。</p>
<p>父亲死了,母亲下落不明。他自己也被卡赞诅咒侵蚀,差点死去。</p>
<p>是师父救了他。</p>
<p>但师父从来没有告诉过他,这诅咒到底是什么来历。</p>
<p>"卡赞……"林克喃喃自语,"你到底是什么?"</p>
<p>没有人回答他。</p>
<p>只有窗外的夜风,吹得树叶沙沙作响。</p>
<p>---</p>
<p>(第三章完)</p>
</article>
</div>
<!-- 固定底部导航 -->
<nav class="fixed-nav">
<div class="fixed-nav-content">
<a href="chapter-2.html" class="nav-btn ">上一章</a>
<a href="../chapters.html" class="nav-btn">目录</a>
<a href="chapter-4.html" class="nav-btn ">下一章</a>
</div>
</nav>
<!-- 右侧滚动按钮 -->
<div class="scroll-buttons">
<button class="scroll-btn" id="scrollTop" title="回到顶部"></button>
<button class="scroll-btn" id="scrollBottom" title="回到底部"></button>
</div>
<!-- 侧边栏章节导航 -->
<aside class="sidebar">
<div class="sidebar-title">章节导航</div>
<div class="sidebar-content" id="sidebarContent">
<a href="chapter-1.html" class="sidebar-chapter">第1章洛兰的风</a>
<a href="chapter-2.html" class="sidebar-chapter">第2章洛兰深处</a>
<a href="chapter-3.html" class="sidebar-chapter current">第3章幽暗密林</a>
<a href="chapter-4.html" class="sidebar-chapter">第4章幽暗密林深处</a>
<a href="chapter-5.html" class="sidebar-chapter">第5章雷鸣废墟</a>
<a href="chapter-6.html" class="sidebar-chapter">第6章格拉卡</a>
<a href="chapter-7.html" class="sidebar-chapter">第7章烈焰格拉卡</a>
<a href="chapter-8.html" class="sidebar-chapter">第8章冰霜幽暗密林</a>
<a href="chapter-9.html" class="sidebar-chapter">第9章转职之路</a>
<a href="chapter-10.html" class="sidebar-chapter">第10章暗黑雷鸣废墟</a>
<a href="chapter-11.html" class="sidebar-chapter">第11章剑魂转职仪式</a>
<a href="chapter-12.html" class="sidebar-chapter">第12章西海岸</a>
<a href="chapter-13.html" class="sidebar-chapter">第13章龙人之塔</a>
<a href="chapter-14.html" class="sidebar-chapter">第14章人偶玄关</a>
<a href="chapter-15.html" class="sidebar-chapter">第15章石巨人塔</a>
<a href="chapter-16.html" class="sidebar-chapter">第16章黑暗玄廊</a>
<a href="chapter-17.html" class="sidebar-chapter">第17章城主宫殿</a>
<a href="chapter-18.html" class="sidebar-chapter">第18章番外·悬空城</a>
<a href="chapter-19.html" class="sidebar-chapter">第19章天帷巨兽·神殿外围</a>
<a href="chapter-20.html" class="sidebar-chapter">第20章树精丛林</a>
<a href="chapter-21.html" class="sidebar-chapter">第21章炼狱</a>
<a href="chapter-22.html" class="sidebar-chapter">第22章西海岸的闲暇</a>
<a href="chapter-23.html" class="sidebar-chapter">第23章极昼</a>
<a href="chapter-24.html" class="sidebar-chapter">第24章第一脊椎</a>
<a href="chapter-25.html" class="sidebar-chapter">第25章赫顿玛尔的准备</a>
<a href="chapter-26.html" class="sidebar-chapter">第26章第二脊椎</a>
<a href="chapter-27.html" class="sidebar-chapter">第27章重逢的温柔</a>
<a href="chapter-28.html" class="sidebar-chapter">第28章暗精灵的委托</a>
<a href="chapter-29.html" class="sidebar-chapter">第29章阿法利亚营地</a>
<a href="chapter-30.html" class="sidebar-chapter">第30章浅栖之地</a>
<a href="chapter-31.html" class="sidebar-chapter">第31章蜘蛛洞穴</a>
<a href="chapter-32.html" class="sidebar-chapter">第32章克伦特的委托</a>
<a href="chapter-33.html" class="sidebar-chapter">第33章暗精灵墓地·左翼守卫</a>
<a href="chapter-34.html" class="sidebar-chapter">第34章暗精灵墓地·剩余三将军</a>
</div>
</aside>
<script>
// 记录阅读进度
let readChapters = JSON.parse(localStorage.getItem('readChapters') || '[]');
if (!readChapters.includes(3)) {
readChapters.push(3);
localStorage.setItem('readChapters', JSON.stringify(readChapters));
}
// 主题切换
const themeToggle = document.getElementById('themeToggle');
const savedTheme = localStorage.getItem('theme') || 'dark';
document.documentElement.setAttribute('data-theme', savedTheme);
themeToggle.textContent = savedTheme === 'dark' ? '浅色' : '深色';
themeToggle.addEventListener('click', () => {
const currentTheme = document.documentElement.getAttribute('data-theme');
const newTheme = currentTheme === 'dark' ? 'light' : 'dark';
document.documentElement.setAttribute('data-theme', newTheme);
localStorage.setItem('theme', newTheme);
themeToggle.textContent = newTheme === 'dark' ? '浅色' : '深色';
});
// 滚动到顶部
document.getElementById('scrollTop').addEventListener('click', () => {
window.scrollTo({ top: 0, behavior: 'smooth' });
});
// 滚动到底部
document.getElementById('scrollBottom').addEventListener('click', () => {
window.scrollTo({ top: document.body.scrollHeight, behavior: 'smooth' });
});
// 页面加载时,侧边栏自动滚动到当前章节
window.addEventListener('load', () => {
const sidebarContent = document.getElementById('sidebarContent');
const currentChapter = sidebarContent.querySelector('.current');
if (currentChapter) {
currentChapter.scrollIntoView({ behavior: 'smooth', block: 'center' });
}
});
</script>
</body>
</html>