diff --git a/.changeset/element-plus-theme-switch.md b/.changeset/element-plus-theme-switch.md new file mode 100644 index 000000000..d0c07d83d --- /dev/null +++ b/.changeset/element-plus-theme-switch.md @@ -0,0 +1,5 @@ +--- +"@vben/layouts": patch +--- + +fix: update primary color when toggling dark/light mode with custom theme diff --git a/packages/effects/layouts/src/widgets/preferences/blocks/theme/builtin.vue b/packages/effects/layouts/src/widgets/preferences/blocks/theme/builtin.vue index 1bb142aee..c262eeb96 100644 --- a/packages/effects/layouts/src/widgets/preferences/blocks/theme/builtin.vue +++ b/packages/effects/layouts/src/widgets/preferences/blocks/theme/builtin.vue @@ -103,7 +103,7 @@ function selectColor() { watch( () => [modelValue.value, props.isDark] as [BuiltinThemeType, boolean], - ([themeType, isDark], [_, isDarkPrev]) => { + ([themeType, isDark]) => { const theme = builtinThemePresets.value.find( (item) => item.type === themeType, ); @@ -112,9 +112,7 @@ watch( ? theme.darkPrimaryColor || theme.primaryColor : theme.primaryColor; - if (!(theme.type === 'custom' && isDark !== isDarkPrev)) { - themeColorPrimary.value = primaryColor || theme.color; - } + themeColorPrimary.value = primaryColor || theme.color; } }, );