fix(themeHandler): properly keep track of color theme when using preset (#4459)

This commit is contained in:
rhld16
2025-12-19 23:51:33 +00:00
committed by GitHub
parent 574741cb5c
commit 89ec4df6a5
2 changed files with 3 additions and 7 deletions

View File

@@ -202,6 +202,7 @@ onMounted(async () => {
})
watch(selectedColor, async (color) => {
if (!color) return;
const theme = generateThemeFromColor(color)
themeRegistry[`color-${color}`] = theme
// Explicitly set the theme to override any previous selection
@@ -225,7 +226,7 @@ const toggleAmoled = () => {
<button
:class="[
'inline-block w-6 h-6 rounded-full transition-all duration-200 border-2',
selectedColor === color
(themeName && themeName.value === `color-${color}`)
? 'border-slate-200 dark:border-slate-400 shadow-lg'
: 'border-transparent'
]"
@@ -248,7 +249,7 @@ const toggleAmoled = () => {
? 'border-slate-200 dark:border-slate-400 shadow-lg'
: 'border-transparent'
]"
@click="setTheme(t)"
@click="selectedColor = '' as ColorNames; setTheme(t)"
:title="themeRegistry[t].displayName"
>
<span

View File

@@ -97,11 +97,6 @@ export class ThemeHandler {
if (mode === 'dark' && this.amoledEnabled.value) {
root.classList.add('amoled')
}
// Add dark class for backward compatibility with VitePress
if (mode === 'dark') {
root.classList.add('dark')
}
}
private applyCSSVariables(colors: ModeColors, theme: Theme) {