Skip to content

Commit 87caf17

Browse files
committed
fix: builtin color change throttled in preference drawer
1 parent f46ec30 commit 87caf17

File tree

1 file changed

+12
-1
lines changed
  • packages/effects/layouts/src/widgets/preferences/blocks/theme

1 file changed

+12
-1
lines changed

packages/effects/layouts/src/widgets/preferences/blocks/theme/builtin.vue

+12-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import { $t } from '@vben/locales';
99
import { BUILT_IN_THEME_PRESETS } from '@vben/preferences';
1010
import { convertToHsl, TinyColor } from '@vben/utils';
1111
12+
import { useThrottleFn } from '@vueuse/core';
13+
1214
defineOptions({
1315
name: 'PreferenceBuiltinTheme',
1416
});
@@ -19,6 +21,15 @@ const colorInput = ref();
1921
const modelValue = defineModel<BuiltinThemeType>({ default: 'default' });
2022
const themeColorPrimary = defineModel<string>('themeColorPrimary');
2123
24+
const updateThemeColorPrimary = useThrottleFn(
25+
(value: string) => {
26+
themeColorPrimary.value = value;
27+
},
28+
300,
29+
true,
30+
true,
31+
);
32+
2233
const inputValue = computed(() => {
2334
return new TinyColor(themeColorPrimary.value || '').toHexString();
2435
});
@@ -84,7 +95,7 @@ function handleSelect(theme: BuiltinThemePreset) {
8495
8596
function handleInputChange(e: Event) {
8697
const target = e.target as HTMLInputElement;
87-
themeColorPrimary.value = convertToHsl(target.value);
98+
updateThemeColorPrimary(convertToHsl(target.value));
8899
}
89100
90101
function selectColor() {

0 commit comments

Comments
 (0)