type StatusType = 'success' | 'error' | 'warning' | 'default' | 'processing'; interface StatusDotProps { status: StatusType | boolean; text?: string; className?: string; } export function StatusDot({ status, text, className = '' }: StatusDotProps) { // 如果status是布尔值,则转换为对应的状态类型 const statusType = typeof status === 'boolean' ? (status ? 'success' : 'default') : status; // 如果没有提供文本,则根据状态类型提供默认文本 const statusText = text ?? ( statusType === 'success' ? '启用' : statusType === 'error' ? '禁用' : statusType === 'warning' ? '警告' : statusType === 'processing' ? '处理中' : '未知' ); return ( {statusText} ); }