- updateNavButtons: 改用数组索引查找,而非简单的+1/-1 - updateSidebarHighlight: 使用parseFloat比较章节ID - updateMobileTOCHighlight: 使用parseFloat比较章节ID - 更新版本号强制刷新缓存
551 lines
23 KiB
HTML
551 lines
23 KiB
HTML
<!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 6</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>
|
||
</article>
|
||
</div>
|
||
|
||
<!-- 固定底部导航 -->
|
||
<nav class="fixed-nav">
|
||
<div class="fixed-nav-content">
|
||
<a href="chapter-5.html" class="nav-btn ">上一章</a>
|
||
<a href="../chapters.html" class="nav-btn">目录</a>
|
||
<a href="chapter-7.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">第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 current">第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(6)) {
|
||
readChapters.push(6);
|
||
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> |