前端添加中英文切换

This commit is contained in:
Dev
2026-11-02 16:43:15 +08:00
parent 41ca22f59e
commit 061fa9d029
22 changed files with 817 additions and 246 deletions
+12 -9
View File
@@ -1,5 +1,7 @@
import React, { useEffect, useState, useRef, useCallback } from 'react';
import { createPortal } from 'react-dom';
import { useLanguage } from '../i18n/LanguageContext';
import { MessageKey } from '../i18n/translations';
interface GenerationProgressProps {
progress: number;
@@ -16,13 +18,13 @@ const STEP_ICONS: Record<string, string> = {
building: '🏗️',
};
const STEP_DETAILS: Record<string, string> = {
analyzing: '分析目标',
connecting: '连接模型',
generating: '生成计划',
parsing: '解析响应',
saving: '保存数据',
building: '构建任务',
const STEP_KEYS: Record<string, MessageKey> = {
analyzing: 'stepAnalyzing',
connecting: 'stepConnecting',
generating: 'stepGenerating',
parsing: 'stepParsing',
saving: 'stepSaving',
building: 'stepBuilding',
};
const TICK_MS = 200;
@@ -30,6 +32,7 @@ const SIM_CEILING = 99;
const GENERATE_DURATION_MS = 120000;
const GenerationProgress: React.FC<GenerationProgressProps> = ({ progress, message, step }) => {
const { t } = useLanguage();
const [displayProgress, setDisplayProgress] = useState(0);
const [dots, setDots] = useState('');
const realProgressRef = useRef(progress);
@@ -107,7 +110,7 @@ const GenerationProgress: React.FC<GenerationProgressProps> = ({ progress, messa
</div>
<div className="flex-1 min-w-0">
<h3 className="text-base font-bold text-slate-800 dark:text-slate-100">
AI 正在为你制定计划
{t('generatingTitle')}
</h3>
<p className="text-sm text-slate-500 dark:text-slate-400 truncate">
{message}{dots}
@@ -162,7 +165,7 @@ const GenerationProgress: React.FC<GenerationProgressProps> = ({ progress, messa
: 'text-slate-400 dark:text-slate-500'
}`}
>
{STEP_DETAILS[s]}
{t(STEP_KEYS[s])}
</span>
</div>
);