chore(appearance): 删除未被注册的 dark-mode 死插件 - #81
Merged
PoxenStudio merged 1 commit intoSep 20, 2026
Merged
PoxenStudio merged 1 commit into
PoxenStudio merged 1 commit into
Conversation
app/src/plugins/dark-mode.js 是一段三重失效的死代码,删除:
1. 从未被注册。nuxt.config.js 的 plugins 只注册了 mybooks / load-plugins /
i18n / appearance,全仓没有任何地方 import 或引用它。
2. 它读的 localStorage key `darkMode` 从来没有写入侧。全历史检索
`git log -S "setItem('darkMode'" --all` 为空,当前 app/src 下 30 余处
localStorage.setItem 也没有这个 key —— 从加入那天起它就是半成品。
真正的键是 `appearance_settings`(app/src/utils/appearance.js 的 STORAGE_KEY)。
3. 即便跑起来也是空转。它只给 <html> 加/去 `dark` class,而全仓 CSS/Vue 里
没有任何 `html.dark` / `.dark` 选择器(只有 Vuetify 自带的 `.theme--dark`)。
它唯一的消费者是 Tailwind 的 `darkMode: 'class'`,而 Tailwind 已随
335ada9(“直接使用vuetify切换样式,去除tailwindcss”)整体移除。
现状的深浅色机制是 `data-appearance-dark` 属性(app/src/app.html 的首帧脚本 +
app/src/utils/appearance.js)+ `vuetify.theme.dark`,与本文件无关。
成因:335ada9a 已删除本文件并撤掉插件注册,但后面的 111d0df(作者时间早于
335ada9、committer 时间晚于它,且其 settings.vue 片段里残留未解决的冲突标记)
把该文件当成新文件又加了回来,于是留下这个没有注册的孤儿文件。
删除后行为完全不变。
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.
这个 PR 做什么
删除
app/src/plugins/dark-mode.js—— 一个三重失效的死文件。删除后行为完全不变,改动只有 1 个文件、11 行删除。为什么它是死代码(三条独立证据)
1. 从来没有被注册
app/nuxt.config.js的plugins只注册了四个:全仓(排除
.git/node_modules)没有任何地方import或引用plugins/dark-mode.js。2. 它读的 localStorage key 从来没有写入侧
getItem('darkMode')只出现在这一行;git log -S "setItem('darkMode'" --all的结果为空 —— 这个 key 从被加入那天起就没有人写过;app/src下 30 余处localStorage.setItem也没有这个 key。真正的键是
appearance_settings(app/src/utils/appearance.js的STORAGE_KEY),走readCache()/writeCache()读写。3. 即便跑起来也只是空转
它只做
document.documentElement.classList.add/remove('dark'),但全仓所有 CSS / Vue 里没有任何html.dark/.dark选择器(搜出来只有 Vuetify 自带的.theme--dark,见app/src/assets/css/scrollbar.css)。它唯一的消费者是 Tailwind 的
darkMode: 'class',而 Tailwind 已随335ada9a(直接使用vuetify切换样式,去除tailwindcss)整体移除,app/tailwind.config.js、postcss.config.js与相关依赖都已不存在。现在的深浅色机制是
data-appearance-dark属性(app/src/app.html的首帧防闪烁脚本 +app/src/utils/appearance.js的applyAppearance())+vuetify.theme.dark,与本文件无关。它是怎么活下来的(顺带发现的历史问题)
53c0be56plugins(Tailwind 时代)335ada9a111d0df8111d0df8的作者时间是 06-14 18:00、committer 时间是 06-15 11:33,晚于335ada9a(06-14 18:07),且git merge-base --is-ancestor 335ada9a 111d0df8为真。它的 diff 里还残留着未解决的冲突标记:也就是说:一次冲突解决不完整的合并把已删文件复活成了孤儿(插件注册与 Tailwind 都没跟着回来)。冲突标记本身后来被清理了,
HEAD里已无残留,所以只留下这个没有注册的插件文件。顺带说明
{ src: "~/plugins/appearance.js", mode: "client" },没有删除本文件,两者不冲突;本 PR 基于develop(dd190ef8),可独立合并。