import React from 'react'; import { Tag } from 'antd'; import { useDictStore } from '@/stores/useDictStore'; interface DictTagProps { type: string; value: string | number | undefined; } const colorMap: Record = { default: 'default', primary: 'blue', success: 'green', warning: 'orange', danger: 'red', info: 'cyan', }; const DictTag: React.FC = ({ type, value }) => { const getDictOptions = useDictStore((s) => s.getDictOptions); if (value === undefined || value === null) return null; const options = getDictOptions(type); const item = options.find((d) => String(d.value) === String(value)); if (!item) return {value}; const color = colorMap[item.colorType] || item.colorType || 'default'; return {item.label}; }; export default DictTag;