// code-snippet-block.tsx — 代码片段展示 + 外侧复制按钮 // Logan.Li import { CopyButton } from '@/components/ui/copy-button'; import { useTranslation } from 'react-i18next'; import { cn } from '@/lib/utils'; export interface CodeSnippetBlockProps { label?: string; code: string; copyLabel?: string; className?: string; /** 无密钥等场景禁用复制 // Logan.Li */ copyDisabled?: boolean; copyDisabledTitle?: string; } export function CodeSnippetBlock({ label, code, copyLabel, className, copyDisabled, copyDisabledTitle, }: CodeSnippetBlockProps) { const { t } = useTranslation(); const resolvedCopyLabel = copyLabel ?? t('common.copied'); return (
{label}
) : ( )}
{code}