feat(theme): add theme toggle and pre-mount theme bootstrap

Add a self-contained theme toggle component under
public/src/components/theme/ that toggles the dark class on the root
element and stores the choice under the beat-theme key in
localStorage. Apply the stored theme, or the prefers-color-scheme
default when nothing is stored, before the app mounts so a cold load
never paints the wrong theme.

The pre-paint script in index.html and both 404 copies reads the same
beat-theme key, so the theme is already on the root element when the
first frame is painted.
This commit is contained in:
Locust agent
2026-11-02 18:03:56 +00:00
parent bbb9ce3ae9
commit 640a04d483
7 changed files with 147 additions and 48 deletions
+5
View File
@@ -1,8 +1,13 @@
import { createApp } from 'vue'
import App from './App.vue'
import router from './router'
import { initializeTheme } from './components/theme/theme'
import './assets/styles/main.css'
// The theme is applied before the app mounts, so a cold load never paints the
// wrong theme first.
initializeTheme()
const app = createApp(App)
app.use(router)
app.mount('#app')