fix: menu-badge color not correct (#4089)

This commit is contained in:
Li Kui
2024-08-09 10:52:47 +08:00
committed by GitHub
parent 3f04f6b01f
commit de90b07b6f
3 changed files with 43 additions and 8 deletions

View File

@@ -3,7 +3,7 @@ import type { MenuRecordBadgeRaw } from '@vben-core/typings';
import { computed } from 'vue';
import { convertToRgb } from '@vben-core/shared';
import { isValidColor } from '@vben-core/shared';
import BadgeDot from './menu-badge-dot.vue';
@@ -15,10 +15,10 @@ const props = withDefaults(defineProps<Props>(), {});
const variantsMap: Record<string, string> = {
default: 'bg-green-500',
destructive: ' bg-destructive',
destructive: 'bg-destructive',
primary: 'bg-primary',
success: ' bg-green-500',
warning: ' bg-yellow-500',
success: 'bg-green-500',
warning: 'bg-yellow-500',
};
const isDot = computed(() => props.badgeType === 'dot');
@@ -34,9 +34,9 @@ const badgeClass = computed(() => {
});
const badgeStyle = computed(() => {
if (badgeClass.value) {
if (badgeClass.value && isValidColor(badgeClass.value)) {
return {
backgroundColor: convertToRgb(badgeClass.value),
backgroundColor: badgeClass.value,
};
}
return {};