fix: warn defineProps is a compiler macro and no longer needs to be imported

pull/78/head
xingyu4j 2025-04-22 11:28:31 +08:00
parent da3fd5b718
commit 062111502f
1 changed files with 37 additions and 22 deletions

View File

@ -1,57 +1,72 @@
<script setup lang="ts">
// TODO @ src
import { computed, defineProps } from 'vue'
import { Tag } from 'ant-design-vue'
import { computed } from 'vue';
import { Tag } from 'ant-design-vue';
// import { isHexColor } from '@/utils/color' // TODO @ cssClass https://gitee.com/yudaocode/yudao-ui-admin-vben/blob/v2.4.1/src/components/DictTag/src/DictTag.vue#L60
import { getDictObj } from '#/utils/dict'
import { getDictObj } from '#/utils/dict';
interface DictTagProps {
/**
* 字典类型
*/
type: string
type: string;
/**
* 字典值
*/
value: any
value: any;
/**
* 图标
*/
icon?: string
icon?: string;
}
const props = defineProps<DictTagProps>()
const props = defineProps<DictTagProps>();
/** 获取字典标签 */
const dictTag = computed(() => {
//
if (!props.type || props.value === undefined || props.value === null) {
return null
return null;
}
//
const dict = getDictObj(props.type, String(props.value))
const dict = getDictObj(props.type, String(props.value));
if (!dict) {
return null
return null;
}
//
let colorType = dict.colorType
if (colorType === 'primary') {
colorType = 'processing'
} else if (colorType === 'danger') {
colorType = 'error'
} else if (colorType === 'info') {
colorType = 'default'
} else if (!colorType) {
colorType = 'default'
let colorType = dict.colorType;
switch (colorType) {
case 'danger': {
colorType = 'error';
break;
}
case 'info': {
colorType = 'default';
break;
}
case 'primary': {
colorType = 'processing';
break;
}
default: {
if (!colorType) {
colorType = 'default';
}
}
}
return {
label: dict.label || '',
colorType
}
})
colorType,
};
});
</script>
<template>