aa23a263fe
- 移除 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>
58 lines
2.2 KiB
TypeScript
58 lines
2.2 KiB
TypeScript
import TextInputArea from '@/components/TextInputArea';
|
|
import QrCodePreview from '@/components/QrCodePreview';
|
|
import { useI18n } from '@/utils/chromeI18n';
|
|
import { useQrCodeContext } from '../contexts/QrCodeContext';
|
|
import { Label } from '@/components/ui/label';
|
|
import { cn } from '@/lib/utils';
|
|
|
|
export default function GeneratePanel() {
|
|
const { t } = useI18n('qrCode');
|
|
const { generatorState, setTextToEncode, downloadQrCode, copyQrCode } = useQrCodeContext();
|
|
|
|
return (
|
|
<div className="grid grid-cols-1 md:grid-cols-2 gap-6 w-full items-stretch select-none p-0.5">
|
|
{/* 左翼:高性能受控输入翼终端 */}
|
|
<div
|
|
className={cn(
|
|
'border border-border rounded-xl bg-card text-card-foreground shadow-sm flex flex-col p-4',
|
|
'focus-within:ring-1 focus-within:ring-ring focus-within:border-ring',
|
|
)}
|
|
>
|
|
{/* 💡 2. 独立外置标签架(A11y 无障碍对齐):
|
|
- 彻底删掉 TextInputArea 上引发崩溃的违规属性。
|
|
- 改用正统的 <Label />,并注入标准的高度无障碍样式,间距比例极度平滑。
|
|
*/}
|
|
<div className="flex flex-col space-y-2.5 h-full">
|
|
<Label className="text-[10px] font-bold text-muted-foreground/90 uppercase tracking-wider select-none pl-0.5">
|
|
{t('qrCode:urlInputLabel')}
|
|
</Label>
|
|
|
|
<div className="flex-1 min-h-0">
|
|
<TextInputArea
|
|
value={generatorState.textToEncode}
|
|
onChange={setTextToEncode}
|
|
placeholder={t('qrCode:urlInputPlaceholder')}
|
|
showCount={true}
|
|
showClear={true}
|
|
allowCopy={true}
|
|
minRows={6}
|
|
maxRows={12}
|
|
externalError={generatorState.inputError || undefined}
|
|
onClear={() => setTextToEncode('')}
|
|
/>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
{/* 右翼:活态二维码高精生成区 */}
|
|
<div className="flex flex-col h-full">
|
|
<QrCodePreview
|
|
qrCodeDataUrl={generatorState.qrCodeDataUrl}
|
|
onDownload={downloadQrCode}
|
|
onCopy={copyQrCode}
|
|
/>
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|