feat: dict tag supper hexColor
parent
c805449973
commit
789f202e55
|
@ -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>
|
||||||
|
|
Loading…
Reference in New Issue