<!DOCTYPE html><html lang="zh" data-theme="dark"><head><meta charset="utf-8"><meta name="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1"><title>观《玩具熊的五夜后宫 2》 · Cytrogen 的个人博客</title><meta name="description" content="前段时间和朋友一起去看《玩具熊的五夜后宫 2》电影(以下简称 FNAF2 电影)。本来打算自己一个人去的,看她在家里无所事事的,干脆抓过来和我一起观赏电影。"><link rel="icon" href="../favicon.png"><link rel="canonical" href="https://cytrogen.icu/posts/5097.html"><link rel="webmention" href="https://webmention.io/cytrogen.icu/webmention"><link rel="me" href="https://m.otter.homes/@Cytrogen"><link rel="me" href="https://github.com/cytrogen"><meta name="fediverse:creator" content="@Cytrogen@m.otter.homes"><link rel="preload" href="../fonts/opensans-regular-latin.woff2" as="font" type="font/woff2" crossorigin="anonymous"><style>@font-face {
font-family: 'Open Sans';
src: url('../fonts/opensans-regular-latin.woff2') format('woff2');
font-weight: 400;
font-style: normal;
font-display: swap;
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
size-adjust: 107%;
ascent-override: 97%;
descent-override: 25%;
line-gap-override: 0%;
}
</style><script>(function() {
try {
// 优先级:用户选择 > 系统偏好 > 默认浅色
const saved = localStorage.getItem('theme');
const theme = saved ||
(window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light');
document.documentElement.setAttribute('data-theme', theme);
document.documentElement.style.colorScheme = theme;
} catch (error) {
// 失败时使用默认主题,不阻塞渲染
document.documentElement.setAttribute('data-theme', 'light');
}
})();
</script><link rel="stylesheet" href="../css/ares.css"><script data-netlify-skip-bundle="true">(function() {
document.addEventListener('DOMContentLoaded', function() {
const theme = document.documentElement.getAttribute('data-theme');
const pageWrapper = document.getElementById('page-wrapper');
if (pageWrapper && theme) {
pageWrapper.setAttribute('data-theme', theme);
}
});
})();
</script><!-- hexo injector head_end start -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.12.0/dist/katex.min.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/hexo-math@4.0.0/dist/style.css">
<!-- hexo injector head_end end --><meta name="generator" content="Hexo 8.1.1"><link rel="alternate" href="atom.xml" title="Cytrogen 的个人博客" type="application/atom+xml">
</head><body><div id="page-wrapper"><a class="skip-link" href="#main-content">跳到主要内容</a><div class="wrap"><header><a class="logo-link" href="../index.html"><img src="../favicon.png" alt="logo"></a><div class="h-card visually-hidden"><img class="u-photo" src="https://cytrogen.icu/favicon.png" alt="Cytrogen"><a class="p-name u-url u-uid" href="https://cytrogen.icu">Cytrogen</a><p class="p-note">Cytrogen 的个人博客,Cytrogen's Blog</p><a class="u-url" rel="me noopener" target="_blank" href="https://m.otter.homes/@Cytrogen">Mastodon</a><a class="u-url" rel="me noopener" target="_blank" href="https://github.com/cytrogen">GitHub</a></div><nav class="site-nav"><div class="nav-main"><div class="nav-primary"><ul class="nav-list hidden-mobile"><li class="nav-item"><a class="nav-link" href="../index.html">首页</a></li></ul><div class="nav-tools"><div class="language-menu"><button class="language-toggle" type="button"><svg class="icon icon-globe" width="16" height="16" viewBox="0 0 16 16" fill="currentColor" aria-hidden="true" focusable="false"><path d="M0 8a8 8 0 1 1 16 0A8 8 0 0 1 0 8zm7.5-6.923c-.67.204-1.335.82-1.887 1.855A7.97 7.97 0 0 0 5.145 4H7.5V1.077zM4.09 4a9.267 9.267 0 0 1 .64-1.539 6.7 6.7 0 0 1 .597-.933A7.025 7.025 0 0 0 2.255 4H4.09zm-.582 3.5c.03-.877.138-1.718.312-2.5H1.674a6.958 6.958 0 0 0-.656 2.5h2.49zM4.847 5a12.5 12.5 0 0 0-.338 2.5H7.5V5H4.847zM8.5 5v2.5h2.99a12.495 12.495 0 0 0-.337-2.5H8.5zM4.51 8.5a12.5 12.5 0 0 0 .337 2.5H7.5V8.5H4.51zm3.99 0V11h2.653c.187-.765.306-1.608.338-2.5H8.5zM5.145 12c.138.386.295.744.468 1.068.552 1.035 1.218 1.65 1.887 1.855V12H5.145zm.182 2.472a6.696 6.696 0 0 1-.597-.933A9.268 9.268 0 0 1 4.09 12H2.255a7.024 7.024 0 0 0 3.072 2.472zM3.82 11a13.652 13.652 0 0 1-.312-2.5h-2.49c.062.89.291 1.733.656 2.5H3.82zm6.853 3.472A7.024 7.024 0 0 0 13.745 12H11.91a9.27 9.27 0 0 1-.64 1.539 6.688 6.688 0 0 1-.597.933zM8.5 12v2.923c.67-.204 1.335-.82 1.887-1.855A7.97 7.97 0 0 0 10.855 12H8.5zm3.68-1h2.146c.365-.767.594-1.61.656-2.5h-2.49a13.65 13.65 0 0 1-.312 2.5zm2.802-3.5a6.959 6.959 0 0 0-.656-2.5H12.18c.174.782.282 1.623.312 2.5h2.49zM11.27 2.461c.247.464.462.98.64 1.539h1.835a7.024 7.024 0 0 0-3.072-2.472c.218.284.418.598.597.933zM10.855 4a7.966 7.966 0 0 0-.468-1.068C9.835 1.897 9.17 1.282 8.5 1.077V4h2.355z"></path></svg><span>中文</span></button><div class="language-dropdown"></div></div></div><div class="nav-controls"><div class="more-menu hidden-mobile"><button class="more-toggle" type="button"><span>更多</span><svg class="icon icon-chevron-down" width="12" height="12" viewBox="0 0 12 12" fill="currentColor" aria-hidden="true" focusable="false"><path d="M6 8.825c-.2 0-.4-.1-.5-.2l-3.3-3.3c-.3-.3-.3-.8 0-1.1s.8-.3 1.1 0l2.7 2.7 2.7-2.7c.3-.3.8-.3 1.1 0s.3.8 0 1.1l-3.3 3.3c-.1.1-.3.2-.5.2z"></path></svg></button><div class="more-dropdown"><ul class="dropdown-list"><li class="dropdown-item"><a class="nav-link" href="../archives/index.html">归档</a></li><li class="dropdown-item"><a class="nav-link" href="../categories/index.html">分类</a></li><li class="dropdown-item"><a class="nav-link" href="../tags/index.html">标签</a></li><li class="dropdown-item"><a class="nav-link" href="../about/index.html">关于</a></li><li class="dropdown-item"><a class="nav-link" href="../sitemap/index.html">领地地图</a></li></ul></div></div><div class="theme-switcher"><button class="theme-toggle" type="button" role="switch" aria-pressed="false" aria-label="切换主题"><div class="theme-icon moon-icon"><svg class="icon icon-moon" width="16" height="16" viewBox="0 0 16 16" fill="currentColor" aria-hidden="true" focusable="false"><path d="M6 .278a.768.768 0 0 1 .08.858 7.208 7.208 0 0 0-.878 3.46c0 4.021 3.278 7.277 7.318 7.277.527 0 1.04-.055 1.533-.16a.787.787 0 0 1 .81.316.733.733 0 0 1-.031.893A8.349 8.349 0 0 1 8.344 16C3.734 16 0 12.286 0 7.71 0 4.266 2.114 1.312 5.124.06A.752.752 0 0 1 6 .278z"></path></svg></div><div class="theme-icon sun-icon"><svg class="icon icon-sun" width="16" height="16" viewBox="0 0 16 16" fill="currentColor" aria-hidden="true" focusable="false"><path d="M8 11a3 3 0 1 1 0-6 3 3 0 0 1 0 6zm0 1a4 4 0 1 0 0-8 4 4 0 0 0 0 8zM8 0a.5.5 0 0 1 .5.5v2a.5.5 0 0 1-1 0v-2A.5.5 0 0 1 8 0zm0 13a.5.5 0 0 1 .5.5v2a.5.5 0 0 1-1 0v-2A.5.5 0 0 1 8 13zm8-5a.5.5 0 0 1-.5.5h-2a.5.5 0 0 1 0-1h2a.5.5 0 0 1 .5.5zM3 8a.5.5 0 0 1-.5.5h-2a.5.5 0 0 1 0-1h2A.5.5 0 0 1 3 8zm10.657-5.657a.5.5 0 0 1 0 .707l-1.414 1.415a.5.5 0 1 1-.707-.708l1.414-1.414a.5.5 0 0 1 .707 0zm-9.193 9.193a.5.5 0 0 1 0 .707L3.05 13.657a.5.5 0 0 1-.707-.707l1.414-1.414a.5.5 0 0 1 .707 0zm9.193 2.121a.5.5 0 0 1-.707 0l-1.414-1.414a.5.5 0 0 1 .707-.707l1.414 1.414a.5.5 0 0 1 0 .707zM4.464 4.465a.5.5 0 0 1-.707 0L2.343 3.05a.5.5 0 1 1 .707-.707l1.414 1.414a.5.5 0 0 1 0 .708z"></path></svg></div></button></div><details class="mobile-menu-details hidden-desktop"><summary class="hamburger-menu" aria-label="nav.menu"><svg class="icon icon-bars" width="16" height="16" viewBox="0 0 16 16" fill="currentColor" aria-hidden="true" focusable="false"><path d="M2.5 12a.5.5 0 0 1 .5-.5h10a.5.5 0 0 1 0 1H3a.5.5 0 0 1-.5-.5zm0-4a.5.5 0 0 1 .5-.5h10a.5.5 0 0 1 0 1H3a.5.5 0 0 1-.5-.5zm0-4a.5.5 0 0 1 .5-.5h10a.5.5 0 0 1 0 1H3a.5.5 0 0 1-.5-.5z"></path></svg><span class="menu-text">nav.menu</span></summary><div class="mobile-menu-dropdown"><ul class="mobile-nav-list"><li class="mobile-nav-item"><a class="mobile-nav-link" href="../index.html">首页</a></li><li class="mobile-nav-item"><a class="mobile-nav-link" href="../archives/index.html">归档</a></li><li class="mobile-nav-item"><a class="mobile-nav-link" href="../categories/index.html">分类</a></li><li class="mobile-nav-item"><a class="mobile-nav-link" href="../tags/index.html">标签</a></li><li class="mobile-nav-item"><a class="mobile-nav-link" href="../about/index.html">关于</a></li><li class="mobile-nav-item"><a class="mobile-nav-link" href="../sitemap/index.html">领地地图</a></li></ul></div></details></div></div></div></nav></header><main class="container" id="main-content" tabindex="-1"><div class="post"><article class="post-block h-entry"><div class="post-meta p-author h-card visually-hidden"><img class="author-avatar u-photo" src="../favicon.png" alt="Cytrogen"><span class="p-name">Cytrogen</span><a class="u-url" href="https://cytrogen.icu">https://cytrogen.icu</a></div><a class="post-permalink u-url u-uid visually-hidden" href="https://cytrogen.icu/posts/5097.html">永久链接</a><div class="p-summary visually-hidden"><p>前段时间和朋友一起去看《玩具熊的五夜后宫 2》电影(以下简称 FNAF2 电影)。本来打算自己一个人去的,看她在家里无所事事的,干脆抓过来和我一起观赏电影。</p></div><div class="visually-hidden"><a class="p-category" href="../categories/%E5%BD%B1%E8%AF%84/">影评</a></div><h1 class="post-title p-name">观《玩具熊的五夜后宫 2》</h1><div class="post-info"><time class="post-date dt-published" datetime="2025-12-23T17:02:31.000Z">12/23/2025</time><time class="dt-updated visually-hidden" datetime="2026-02-09T17:16:55.549Z"></time></div><div class="post-content e-content"><html><head></head><body><p>前段时间和朋友一起去看《玩具熊的五夜后宫 2》电影(以下简称 FNAF2 电影)。本来打算自己一个人去的,看她在家里无所事事的,干脆抓过来和我一起观赏电影。</p>
<span id="more"></span>
<div class="danger warning"><p>不想要被剧透的还是不要看了吧 —— 虽然话是这么说的,但如果你都不想被剧透了,还点进来做什么呢?</p>
</div>
<p>我们去的我校附近的一家 AMC 影院。AMC 好便宜啊,周二周三电影票都半价,有些早上的时间段还额外打个八折或者七五折。不看 IMAX 或者 Dolby 的话,一个人才 10 块钱。</p>
<p>去年还是前年的时候,AMC 忽然送了我一年 Premium 会员。不知道是什么意思,怀疑是生意不好做,我也查不到我这个会员的有效截止期是什么时候。总之除了攒积分快点,我还可以买中号爆米花跟饮料,然后免费升级到大号(虽然两者的区别只有 1 块钱……)。</p>
<p>朋友买了爆米花和饮料,总计 18 块钱。可以免费续,不过没有那个必要,实在是吃不动那么多,一场电影下来爆米花还剩差不多三分之一。饮料倒是喝得很快。她调了个桃子柠檬味雪碧,也就是一点点桃子味雪碧,剩下全部接普通雪碧。味道意外地不错。</p>
<p>我们提前半小时入场,也看了半小时的广告。该说不说,这些广告很「优质」,至少成功地让我出于好奇、扫了一个二维码。不过让我想到了前段时间接收到的一个观点:很多时候花了钱更容易看到这些「优质」的广告。</p>
<p>半小时过后,大荧幕终于开始播放其他电影的预告片 —— 基本上都是那种经典得不得了的外国恐怖 / 血腥片,光是看了预告片就知道实质内容会是什么。</p>
<h2 id="电影中"><a class="markdownIt-Anchor" href="#电影中"></a> 电影中</h2>
<p>说回 FNAF2 电影本身,我看完后第一感想是「这是喜剧片吗?」</p>
<p>首先它作为一部恐怖片严重失格,<strong>所谓的「恐怖」都是靠堆跳杀来实现</strong>。堆的实在是太多了,还很刻意,根本不会让人觉得害怕,只会觉得无趣、重复。</p>
<p>那它作为粉丝向的作品合格吗?</p>
<p>我确实很喜欢电影里面的彩蛋,例如 Mike 吐槽 2 代披萨店的保安室居然没有门。还有开头展示 2 代披萨店时,展示到街机区的时候貌似看到了 Candy 猫的小彩蛋,不知道是不是看错了?不过呢有些地方我觉得可以做得更好,比如老 Foxy 居然不是被闪走的。</p>
<p>Vanessa 和 Mike 前期的约会剧情我挺喜欢的,以及 Vanessa 的梦境剧情。</p>
<p>为了体现出 Vanessa 渴望脱离 William 带给自己的阴影,我认为制作组在这方面上很是用心:成人的 Vanessa 看着走廊尽头的 William,勉强地大喊「我不再怕你了」。William 冲来时她又逃到出口恐慌地拍门、想要离开。下一幕 Vanessa 变成了小孩的样子,逃窜到父亲的工作室。在那里,她找到了 Baby,可能是想要补充游戏世界里 Elizabeth 的设定?总之,电影里的 Vanessa 变成了保安的样子后枪杀了 William,但是倒在地上的 William 依然喊着「你永远都会是我的」。</p>
<p>我认为这一幕很棒地表现出了 William 在 Vanessa 的眼里是多么可怕的存在,就算死了也会一直作为阴影存在。</p>
<p>说完了优点,来说缺点。电影里那种经典的「不好好说话」剧情到处都是,以至于我都不乐意一个个挑出来说 —— 太多了!自然,影视作品一定要有这样的桥段来营造冲突,但我认为可以有更聪明的方式,<strong>至少不要每个冲突点都让我觉得过分刻意吧</strong>!</p>
<p>电影世界在剧情设定上,对游戏原著的魔改程度大得惊人,甚至到了令人困惑的地步。</p>
<div class="danger alert-info"><p>事先说明一下游戏里的主要角色:</p>
<ul>
<li>
<p>William 是主要的反派,他创造了玩偶,并且杀害了多个小孩,也包括自己的女儿 Elizabeth。</p>
<ul>
<li>
<p>Michael 是 William 的大儿子,也是 FNAF 系列的主角,许多作品里玩家所扮演的就是他。</p>
<p>他想要弥补父亲造成的一切、找回妹妹。不过在《姐妹地点》里,他被混合意识体 Ennard 欺骗、挖空了身体、当做 Ennard 出门伪装用的皮囊。最后因为身体腐烂,Ennard 不得不放弃他,而他居然也没有死,实在是打不死的小强啊。</p>
</li>
<li>
<p>Elizabeth 被 William 所做的 Baby 玩偶意外杀死。</p>
</li>
<li>
<p>William 还有个小儿子,不过他的名字从来都没有被提起过,只知道他是 83 之咬的受害者。</p>
</li>
</ul>
</li>
<li>
<p>Henry 是 William 的商业伙伴。</p>
<ul>
<li>Charlotte 是 Henry 的女儿,也是 William 的第一名受害者。死后附身了 Marionette(Puppet,也叫傀儡)。</li>
</ul>
</li>
<li>
<p>Vanessa 就比较特殊了。她是到《安全漏洞》才出现的新角色,这时候 FNAF 游戏已经不再是过去那样的「保安电竞游戏」。正因如此,我对她并不熟悉。</p>
</li>
</ul>
</div>
<p>我因为第 1 部电影而分不清 Vanessa 和 Elizabeth。电影世界里,William 的女儿从 Elizabeth 变成了 Vanessa。主角是 Mike,他的弟弟曾经被 William 拐走杀害,因此留下阴影。</p>
<p>我在 FNAF 小说推出后就没有再怎么关注这个系列了。Vanessa 到底是谁?是 Elizabeth?但是 Elizabeth 不是已经被 Baby 杀了吗?</p>
<p>直到我出了影院搜了一下,才得知游戏世界里的 Vanessa 和 Elizabeth 一点关系都没有。电影世界里其实是将 Michael 的角色位置给了 Vanessa,因为要给 Mike 凑 CP 吗?然后 Elizabeth 的位置给了 Michael,也就是想要和 William 一样杀人的位置。Elizabeth 在电影里查无此人。太乱了。</p>
<p>Michael 因为站在游戏世界里 Elizabeth 的角色位置,所以在电影世界里他认同了 William、变成了反派,刻意释放出 Charlotte 要大杀四方。</p>
<p>这里我忘了为什么 Michael 可以操控 2 代玩偶,不应该是 Charlotte 操控它们吗?我也没有看到 Michael 和 Charlotte 合谋的场面,只有开头 Michael 放出 Charlotte 的场合,但那个时候 Michael 还很怕 Charlotte 会弄死自己。</p>
<p>Charlotte 虽然为了救小男孩而被 William 杀死,但是她并不觉得这是 William 的问题,有错的是当时不愿意帮助她的大人。此处的逻辑我认为是为了让角色变成反派而设计的,就像为什么 1 代玩偶会想要弄死 Abby 一样。说实话很刻意,我不喜欢。</p>
<p>这个片快结尾的时候实在是欢乐得不行:谁想出来的 1 代玩偶痛扁 2 代玩偶的情节的?差点以为回到了十年前看 YouTube 上那些不同版本的玩偶大战、比战力的时候。尤其是制作组很刻意地将这一段设计的非常滑稽 ——Toy Bonnie 的脸被一脚踩烂,眼珠子可笑地漏了出来。我当时看的时候一直在憋笑……</p>
<p>看到 Mike 拿出音乐盒驱散了 Charlotte 时,我觉得应该就这么结束了吧,谁曾想 Mike 直接把音乐盒停了,然后和 Vanessa 大吵一架。这一段吵架戏感觉莫名其妙的,像是为了吵架而吵架一样。Vanessa 绝望的时候,Charlotte 突然出现并俯身了她,全片完……</p>
<p>只是觉得颇为儿戏,这样的设计。</p>
<p>当时灯光亮起,很意外地播放了 <em>It's Been Too Long</em> 这首歌。身后的人起来要走,抱怨了一句「明明电影拍到这儿就行了」。</p>
<p>电影刚开始的时候,提到结尾有彩蛋,因此我和朋友等到了整部电影结束。结尾的彩蛋有两个:William,或者说 SpringTrap 苏醒了过来,暗示着第 3 部电影;Henry 给 Mike 发了个语音提醒?具体说了什么其实我都不记得了,类似于那种「你要小心一个人」,然后在报名之前就被不明生物杀害。</p>
<p>我自己是觉得,这些桥段实在是太经典了。估计第三部电影里,Vanessa 会被其他人嘴炮醒来、和 Charlotte 斗争…… 不过我也不清楚,因为 Mike 明显有救世主情节,想要去「修复」Vanessa,这样的态度让 Vanessa 以及我都感到很生气,所以我大胆猜测一下,也有可能 Vanessa 会治愈自己?总之,我想要看一些不是那么典型的桥段。</p>
<h2 id="电影后"><a class="markdownIt-Anchor" href="#电影后"></a> 电影后</h2>
<p>我和朋友商量着去附近新开的蜜雪冰城。过去一看果不其然,排满了长队。没有办法,价格实在是太便宜了,熊猫外卖上的预售套餐有两个饮品,居然只要 4 美元左右。就算加上平台费、运送费和小费,价格也比附近的奶茶品牌便宜很多很多。</p>
<p>没办法,我们只能到处走走、吐槽这部电影。她觉得电影剧情实在是招人笑,许多情节她后来想想也会觉得可笑。</p>
<p>我也在手机上看到一些人对这部电影的看法:因为这是 FNAF 的电影,所以他们觉得就是好、不该骂。我认为这没必要。</p>
<p>作为 FNAF 系列(曾经的)粉丝,能看到玩偶们以真实的形态动起来很是惊喜,看到各个彩蛋的时候也很高兴。但是这部电影的剧情对我而言就是很不咋地,评价不可能只有黑或者只有白。再就是 <strong>喜欢这个系列,所以希望作品优秀不是很正常的事情吗?怎么能因为它是某某系列的作品,就无视了所有的缺点呢?</strong></p>
<p>不过过了几天我再看这部电影的消息:居然在票房上打败了我还没看的《疯狂动物城 2》。朋友知道后气急败坏地说:「都怪你拉我来看这个,我们居然为这个片的票房贡献了宝贵的两票!」我听后实在是哭笑不得。</p>
</body></html></div></article></div></main><footer><div class="paginator"><a class="prev" href="6e69.html">上一篇</a><a class="next" href="9572.html">下一篇</a></div><!-- Webmention 显示区域--><div class="webmention-section webmention-empty" data-page-url="posts/5097.html" data-full-url="https://cytrogen.icu/posts/5097.html" data-mode="static">
<h3 class="webmention-title">Webmentions (<span class="webmention-count">0</span>)</h3>
<div class="webmention-list"></div>
<span>暂无 Webmentions</span>
</div><div class="copyright"><p class="footer-links"><a href="../friends/index.html">友链</a><span class="footer-separator"> ·</span><a href="../links/index.html">邻邦</a><span class="footer-separator"> ·</span><a href="../contact/index.html">联络</a><span class="footer-separator"> ·</span><a href="../colophon/index.html">营造记</a><span class="footer-separator"> ·</span><a href="../atom.xml">RSS订阅</a></p><p>© 2025 - 2026 <a href="https://cytrogen.icu">Cytrogen</a>, powered by <a href="https://hexo.io/" target="_blank">Hexo</a> and <a href="https://github.com/cytrogen/hexo-theme-ares" target="_blank">hexo-theme-ares</a>.</p><p><a href="https://blogscn.fun" target="_blank" rel="noopener">BLOGS·CN</a></p></div></footer></div></div><a class="back-to-top" href="#top" aria-label="返回顶部"><svg width="20" height="20" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true"><path d="M3.293 9.707a1 1 0 010-1.414L9.586 2a2 2 0 012.828 0l6.293 6.293a1 1 0 01-1.414 1.414L11 3.414V17a1 1 0 11-2 0V3.414L2.707 9.707a1 1 0 01-1.414 0z"></path></svg></a><script>document.addEventListener('DOMContentLoaded', function() {
const codeBlocks = document.querySelectorAll('figure.highlight');
codeBlocks.forEach(block => {
let caption = block.querySelector('figcaption');
if (!caption) {
caption = document.createElement('figcaption');
block.insertBefore(caption, block.firstChild);
}
const info = document.createElement('div');
info.className = 'info';
const filename = caption.querySelector('span');
if (filename) {
filename.className = 'filename';
info.appendChild(filename);
}
const lang = block.className.split(' ')[1];
if (lang) {
const langSpan = document.createElement('span');
langSpan.className = 'lang-name';
langSpan.textContent = lang;
info.appendChild(langSpan);
}
const sourceLink = caption.querySelector('a');
if (sourceLink) {
sourceLink.className = 'source-link';
info.appendChild(sourceLink);
}
const actions = document.createElement('div');
actions.className = 'actions';
const codeHeight = block.scrollHeight;
const threshold = 300;
if (codeHeight > threshold) {
block.classList.add('folded');
const toggleBtn = document.createElement('button');
toggleBtn.textContent = '展开';
toggleBtn.addEventListener('click', () => {
block.classList.toggle('folded');
toggleBtn.textContent = block.classList.contains('folded') ? '展开' : '折叠';
});
actions.appendChild(toggleBtn);
}
const copyBtn = document.createElement('button');
copyBtn.textContent = '复制';
copyBtn.addEventListener('click', async () => {
const codeLines = block.querySelectorAll('.code .line');
const code = Array.from(codeLines)
.map(line => line.textContent)
.join('\n')
.replace(/\n\n/g, '\n');
try {
await navigator.clipboard.writeText(code);
copyBtn.textContent = '已复制';
copyBtn.classList.add('copied');
setTimeout(() => {
copyBtn.textContent = '复制';
copyBtn.classList.remove('copied');
}, 3000);
} catch (err) {
console.error('复制失败:', err);
copyBtn.textContent = '复制失败';
setTimeout(() => {
copyBtn.textContent = '复制';
}, 3000);
}
});
actions.appendChild(copyBtn);
caption.innerHTML = '';
caption.appendChild(info);
caption.appendChild(actions);
const markedLines = block.getAttribute('data-marked-lines');
if (markedLines) {
const lines = markedLines.split(',');
lines.forEach(range => {
if (range.includes('-')) {
const [start, end] = range.split('-').map(Number);
for (let i = start; i <= end; i++) {
const line = block.querySelector(`.line-${i}`);
if (line) line.classList.add('marked');
}
} else {
const line = block.querySelector(`.line-${range}`);
if (line) line.classList.add('marked');
}
});
}
});
});</script><script async src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js" id="MathJax-script"></script><script>(function() {
document.addEventListener('DOMContentLoaded', function() {
const themeToggle = document.querySelector('.theme-toggle');
if (!themeToggle) return;
const getCurrentTheme = () => {
return document.documentElement.getAttribute('data-theme') || 'light';
};
const updateUI = (theme) => {
const isDark = theme === 'dark';
themeToggle.setAttribute('aria-pressed', isDark.toString());
};
const setTheme = (theme) => {
document.documentElement.setAttribute('data-theme', theme);
document.documentElement.style.colorScheme = theme;
const pageWrapper = document.getElementById('page-wrapper');
if (pageWrapper) {
pageWrapper.setAttribute('data-theme', theme);
}
// Find and remove the temporary anti-flicker style tag if it exists.
// This ensures the main stylesheet takes full control after the initial load.
const antiFlickerStyle = document.getElementById('anti-flicker-style');
if (antiFlickerStyle) {
antiFlickerStyle.remove();
}
localStorage.setItem('theme', theme);
updateUI(theme);
};
const toggleTheme = () => {
const current = getCurrentTheme();
const newTheme = current === 'light' ? 'dark' : 'light';
setTheme(newTheme);
};
updateUI(getCurrentTheme());
themeToggle.addEventListener('click', toggleTheme);
if (window.matchMedia) {
const mediaQuery = window.matchMedia('(prefers-color-scheme: dark)');
mediaQuery.addEventListener('change', function(e) {
if (!localStorage.getItem('theme')) {
const theme = e.matches ? 'dark' : 'light';
setTheme(theme);
}
});
}
});
})();
</script><script src="../js/details-toggle.js" defer></script><script>(function() {
document.addEventListener('DOMContentLoaded', function() {
const backToTopBtn = document.querySelector('.back-to-top');
if (!backToTopBtn) return;
const toggleButtonVisibility = () => {
const scrollTop = window.pageYOffset || document.documentElement.scrollTop;
const shouldShow = scrollTop > 200;
if (shouldShow) {
backToTopBtn.classList.add('is-visible');
} else {
backToTopBtn.classList.remove('is-visible');
}
};
let ticking = false;
const handleScroll = () => {
if (!ticking) {
requestAnimationFrame(() => {
toggleButtonVisibility();
ticking = false;
});
ticking = true;
}
};
const scrollToTop = (event) => {
event.preventDefault();
window.scrollTo({
top: 0,
behavior: 'smooth'
});
};
window.addEventListener('scroll', handleScroll);
backToTopBtn.addEventListener('click', scrollToTop);
toggleButtonVisibility();
});
})();</script></body></html>