Files
testing-tool/pages/StorageCleaner/ErrorDisplay.tsx
T
雨霖铃 aa23a263fe refactor: 迁移 i18n 系统从 react-i18next 到 chrome.i18n
- 移除 react-i18next、i18next 及相关依赖
- 删除旧的 i18n/ 目录和 useLazyTranslation 工具
- 新增 utils/chromeI18n.ts 类型安全 wrapper(useI18n Hook + getMessage)
- 生成 public/_locales/{zh,en}/messages.json(298 个翻译 key)
- 批量更新 39+ 组件文件的导入和翻译调用
- 转换翻译键格式:namespace:key → namespace_key
- 修复 ErrorBoundary/PageErrorBoundary 从 withTranslation HOC 改为直接调用 getMessage
- 更新 vitest.setup.ts mock 加载实际翻译文本
- 修复 11 个测试文件的断言以匹配中文翻译
- TypeScript、ESLint、547 项测试全部通过

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-05-28 19:21:54 +08:00

44 lines
1.7 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { AlertCircle } from 'lucide-react';
import { useI18n } from '@/utils/chromeI18n';
import { cn } from '@/lib/utils';
interface ErrorDisplayProps extends React.HTMLAttributes<HTMLDivElement> {
error: string;
}
export default function ErrorDisplay({ error, className, ...props }: ErrorDisplayProps) {
const { t } = useI18n('storageCleaner');
return (
// 1. 精简层级:单层外壳直接搞定居中、响应式高度与外部类名扩展
<div
className={cn(
'flex flex-col items-center justify-center py-8 min-h-[240px] sm:min-h-[360px] p-4 text-center',
className,
)}
{...props}
>
{/* 2. 核心卡片容器:
- 彻底放弃 bg-red-50,改用标准的 bg-destructive/53%~5% 透明度的系统危险色)。
- 边框改为 border-destructive/20。
- 这样在黑夜模式下会自动完美混色,绝不刺眼。
*/}
<div className="w-full max-w-xs flex flex-col items-center justify-center rounded-xl p-5 border border-destructive/20 bg-destructive/5 shadow-sm">
{/* 3. 图标与主要错误信息全面对接 text-destructive 语义色 */}
<div className="flex h-10 w-10 items-center justify-center rounded-full bg-destructive/10 text-destructive mb-3.5 shrink-0">
<AlertCircle className="h-5 w-5" />
</div>
<p className="text-sm font-semibold leading-relaxed text-destructive break-all px-1 mb-2">
{error}
</p>
{/* 次要提示文本维持柔和的中性高级灰 */}
<p className="text-xs font-medium leading-relaxed text-muted-foreground/90 px-2">
{t('storageCleaner:errorStandardOnly')}
</p>
</div>
</div>
);
}