迁移范围: - deploy 模块 (PipelineEditor/PipelineDetailDialog/PipelineFormDialog/PipelineRunDialog/ReleaseCreateDialog/ReleaseDetailDialog/ReleaseManager/ToolConfigTab/JobRoleCreateDialog 等 14 文件) - kubernetes 模块 (YamlEditorToolbar/DeploymentHpaTab/DeploymentLogsTab/DeploymentPodsTab/DnsHostSection/SchedulingSection/EventsTab/HPACronHPATab/HistoryTab/PodsTab/ServicesTab/ActionModals 等 12 文件) - monitor 模块 (AlertEventsTab/AlertCenterDetail/DatasourcePage/LogAlertBell/LogCenter/LogCenterArchBanner/StatChartPanel/LogRoleCreateDialog 等 8 文件) - task 模块 (CronJobStatsPanel/CronJobTable/CronJobViewDialog/ExecutionHistoryDialog 4 文件) - layout (PageEmpty/PageLoading 2 文件) - site-monitor/snmp-monitor 模块 (6 文件) 翻译键: 3975 → 4003 (+28 缺失键补全), 22 命名空间, zh-CN/en-US 完全对齐 新增命名空间: agent/aiops/cloud/kubernetes/monitor/pipeline/rbac/system/task/ui 验证: go build✅ tsc -b=0 npm build✅ (20.78s) 17/17 集成测试通过
46 lines
1.6 KiB
TypeScript
46 lines
1.6 KiB
TypeScript
// 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 (
|
|
<div className={cn('space-y-1.5', className)}>
|
|
<div className="flex items-center justify-between gap-2">
|
|
{label ? (
|
|
<p className="text-xs text-[var(--dg-text-muted)]">{label}</p>
|
|
) : (
|
|
<span />
|
|
)}
|
|
<CopyButton
|
|
text={code}
|
|
label={resolvedCopyLabel}
|
|
variant="outline"
|
|
size="sm"
|
|
className="border-[var(--dg-border)] text-[var(--dg-text-secondary)] h-7 px-2"
|
|
disabled={copyDisabled}
|
|
title={copyDisabled ? (copyDisabledTitle || t('ui.codeSnippet.copyDisabled')) : t('common.copy')}
|
|
>
|
|
{t('common.copy')}
|
|
</CopyButton>
|
|
</div>
|
|
<pre className="text-[11px] font-mono text-[var(--dg-text-secondary)] bg-[var(--dg-bg-secondary)] border border-[var(--dg-border)] rounded-md p-3 overflow-x-auto whitespace-pre-wrap leading-relaxed">
|
|
{code}
|
|
</pre>
|
|
</div>
|
|
);
|
|
} |