Merge branch 'main' of https://github.com/vbenjs/vue-vben-admin into warmflow

This commit is contained in:
dap
2025-01-10 14:24:43 +08:00
25 changed files with 354 additions and 178 deletions

View File

@@ -2,11 +2,12 @@
import type { BuiltinThemePreset } from '@vben/preferences';
import type { BuiltinThemeType } from '@vben/types';
import { computed, ref, watch } from 'vue';
import { UserRoundPen } from '@vben/icons';
import { $t } from '@vben/locales';
import { BUILT_IN_THEME_PRESETS } from '@vben/preferences';
import { convertToHsl, TinyColor } from '@vben/utils';
import { computed, ref } from 'vue';
defineOptions({
name: 'PreferenceBuiltinTheme',
@@ -79,11 +80,6 @@ function typeView(name: BuiltinThemeType) {
function handleSelect(theme: BuiltinThemePreset) {
modelValue.value = theme.type;
const primaryColor = props.isDark
? theme.darkPrimaryColor || theme.primaryColor
: theme.primaryColor;
themeColorPrimary.value = primaryColor || theme.color;
}
function handleInputChange(e: Event) {
@@ -94,6 +90,22 @@ function handleInputChange(e: Event) {
function selectColor() {
colorInput.value?.[0]?.click?.();
}
watch(
() => [modelValue.value, props.isDark] as [BuiltinThemeType, boolean],
([themeType, isDark]) => {
const theme = builtinThemePresets.value.find(
(item) => item.type === themeType,
);
if (theme) {
const primaryColor = isDark
? theme.darkPrimaryColor || theme.primaryColor
: theme.primaryColor;
themeColorPrimary.value = primaryColor || theme.color;
}
},
);
</script>
<template>