fix(site): about.html 补回主题切换脚本,修复暗色模式失效#19
Merged
Conversation
about.html 有主题切换按钮,但既没引 app.js(index 的 initThemeToggle 在此), 也没有其他独立页(catalog/glossary/prereqs/lesson)都带的内联主题脚本,导致按钮 点了无反应、整页钉死在亮色,且不读 localStorage.theme / 系统暗色偏好。 补回与其他页一致的内联主题脚本(读取存储/系统偏好 + 接管 #themeToggle 点击 + 更新图标 + 持久化)。暗色 CSS 本就正常,纯属脚本缺失的接线问题。 上游 rohitg00/ai-engineering-from-scratch 同样存在此问题(本站继承)。
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
问题
about.html有主题切换按钮,但既没引app.js(index 的initThemeToggle()在这里,是全站唯一接管#themeToggle点击的 JS),也没有其他独立页(catalog/glossary/prereqs/lesson)都带的内联主题脚本。结果按钮点了无反应,整页钉死在亮色,且不读localStorage.theme/ 系统prefers-color-scheme。暗色 CSS 本身正常——控制台
document.documentElement.setAttribute("data-theme","dark")能让 about 页正确变暗。纯属脚本缺失的接线问题。修复
补回与其他独立页一致的自包含内联主题脚本(读存储/系统偏好 → 设
data-theme、接管#themeToggle点击、更新N/D图标、持久化)。单文件、纯新增,不影响其他页。验证
本地起静态服务,在 about 页操作切换按钮:
lightdarkdarklightlight修复前点击后
data-theme仍是light(无 handler);修复后正常切换并持久化,与其他页一致。