feat: dict tag supper hexColor

pull/139/head
xingyu4j 2025-06-12 09:59:24 +08:00
parent c805449973
commit 789f202e55
1 changed files with 15 additions and 1 deletions

View File

@ -23,6 +23,11 @@ interface DictTagProps {
const props = defineProps<DictTagProps>(); const props = defineProps<DictTagProps>();
function isHexColor(color: string) {
const reg = /^#(?:[0-9a-f]{3}|[0-9a-f]{6})$/i;
return reg.test(color);
}
/** 获取字典标签 */ /** 获取字典标签 */
const dictTag = computed(() => { const dictTag = computed(() => {
// //
@ -66,7 +71,16 @@ const dictTag = computed(() => {
</script> </script>
<template> <template>
<Tag v-if="dictTag" :color="dictTag.colorType"> <Tag
v-if="dictTag"
:color="
dictTag.colorType
? dictTag.colorType
: dictTag.cssClass && isHexColor(dictTag.cssClass)
? dictTag.cssClass
: ''
"
>
{{ dictTag.label }} {{ dictTag.label }}
</Tag> </Tag>
</template> </template>