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

This commit is contained in:
xingyu4j
2025-04-22 11:28:31 +08:00
parent da3fd5b718
commit 062111502f

View File

@@ -1,57 +1,72 @@
<script setup lang="ts"> <script setup lang="ts">
// TODO @芋艿:貌似不用 src 目录 // TODO @芋艿:貌似不用 src 目录
import { computed, defineProps } from 'vue' import { computed } from 'vue';
import { Tag } from 'ant-design-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 { 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 { 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(() => { const dictTag = computed(() => {
// 校验参数有效性 // 校验参数有效性
if (!props.type || props.value === undefined || props.value === null) { 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) { if (!dict) {
return null return null;
} }
// 处理颜色类型 // 处理颜色类型
let colorType = dict.colorType let colorType = dict.colorType;
if (colorType === 'primary') { switch (colorType) {
colorType = 'processing' case 'danger': {
} else if (colorType === 'danger') { colorType = 'error';
colorType = 'error'
} else if (colorType === 'info') { break;
colorType = 'default' }
} else if (!colorType) { case 'info': {
colorType = 'default' colorType = 'default';
break;
}
case 'primary': {
colorType = 'processing';
break;
}
default: {
if (!colorType) {
colorType = 'default';
}
}
} }
return { return {
label: dict.label || '', label: dict.label || '',
colorType colorType,
} };
}) });
</script> </script>
<template> <template>