i saved theme data locally fuck

This commit is contained in:
Samidy 2025-12-20 15:09:56 +03:00
parent b41e6b3c9b
commit aa5eb9c43b
2 changed files with 4 additions and 7 deletions

View file

@ -260,4 +260,4 @@ const toggleAmoled = () => {
</div>
</div>
</div>
</template>
</template>

View file

@ -21,6 +21,7 @@ import { themeRegistry } from './configs'
const STORAGE_KEY_THEME = 'vitepress-theme-name'
const STORAGE_KEY_MODE = 'vitepress-display-mode'
const STORAGE_KEY_AMOLED = 'vitepress-amoled-enabled'
const STORAGE_KEY_THEME_DATA = 'vitepress-theme-data'
export class ThemeHandler {
private state = ref<ThemeState>({
@ -45,10 +46,6 @@ export class ThemeHandler {
if (themeRegistry[savedTheme]) {
this.state.value.currentTheme = savedTheme
this.state.value.theme = themeRegistry[savedTheme]
} else {
localStorage.removeItem(STORAGE_KEY_THEME)
this.state.value.currentTheme = 'christmas'
this.state.value.theme = themeRegistry.christmas
}
// Set amoled preference
@ -77,7 +74,7 @@ export class ThemeHandler {
})
}
private applyTheme() {
public applyTheme() {
if (typeof document === 'undefined') return
const { currentMode, theme } = this.state.value
@ -393,4 +390,4 @@ export function useTheme() {
toggleAmoled: () => handler.toggleAmoled(),
state
}
}
}