feat(i18n): replace hardcoded Chinese in frontend addLog() messages

This commit is contained in:
ghostubborn
2026-04-01 16:35:35 +08:00
parent 9d43b77511
commit e1db8bacc2
3 changed files with 92 additions and 88 deletions

View File

@@ -683,7 +683,7 @@ watch(currentStage, (newStage) => {
phase.value = 2
// 进入配置生成阶段,开始轮询配置
if (!configTimer) {
addLog('开始生成双平台模拟配置...')
addLog(t('log.startGeneratingConfig'))
startConfigPolling()
}
} else if (newStage === '准备模拟脚本' || newStage === 'copying_scripts') {
@@ -748,10 +748,10 @@ const handleStartSimulation = () => {
if (useCustomRounds.value) {
// 用户自定义轮数,传递 max_rounds 参数
params.maxRounds = customMaxRounds.value
addLog(`开始模拟,自定义轮数: ${customMaxRounds.value}`)
addLog(t('log.startSimCustomRounds', { rounds: customMaxRounds.value }))
} else {
// 用户选择保持自动生成的轮数,不传递 max_rounds 参数
addLog(`开始模拟,使用自动配置轮数: ${autoGeneratedRounds.value}`)
addLog(t('log.startSimAutoRounds', { rounds: autoGeneratedRounds.value }))
}
emit('next-step', params)
@@ -771,15 +771,15 @@ const selectProfile = (profile) => {
// 自动开始准备模拟
const startPrepareSimulation = async () => {
if (!props.simulationId) {
addLog('错误:缺少 simulationId')
addLog(t('log.errorMissingSimId'))
emit('update-status', 'error')
return
}
// 标记第一步完成,开始第二步
phase.value = 1
addLog(`模拟实例已创建: ${props.simulationId}`)
addLog('正在准备模拟环境...')
addLog(t('log.simInstanceCreated', { id: props.simulationId }))
addLog(t('log.preparingSimEnv'))
emit('update-status', 'processing')
try {
@@ -791,35 +791,35 @@ const startPrepareSimulation = async () => {
if (res.success && res.data) {
if (res.data.already_prepared) {
addLog('检测到已有完成的准备工作,直接使用')
addLog(t('log.detectedExistingPrep'))
await loadPreparedData()
return
}
taskId.value = res.data.task_id
addLog(`准备任务已启动`)
addLog(` └─ Task ID: ${res.data.task_id}`)
addLog(t('log.prepareTaskStarted'))
addLog(t('log.prepareTaskId', { taskId: res.data.task_id }))
// 立即设置预期Agent总数从prepare接口返回值获取
if (res.data.expected_entities_count) {
expectedTotal.value = res.data.expected_entities_count
addLog(`从Zep图谱读取到 ${res.data.expected_entities_count} 个实体`)
addLog(t('log.zepEntitiesFound', { count: res.data.expected_entities_count }))
if (res.data.entity_types && res.data.entity_types.length > 0) {
addLog(` └─ 实体类型: ${res.data.entity_types.join(', ')}`)
addLog(t('log.entityTypes', { types: res.data.entity_types.join(', ') }))
}
}
addLog('开始轮询准备进度...')
addLog(t('log.startPollingProgress'))
// 开始轮询进度
startPolling()
// 开始实时获取 Profiles
startProfilesPolling()
} else {
addLog(`准备失败: ${res.error || '未知错误'}`)
addLog(t('log.prepareFailed', { error: res.error || t('common.unknownError') }))
emit('update-status', 'error')
}
} catch (err) {
addLog(`准备异常: ${err.message}`)
addLog(t('log.prepareException', { error: err.message }))
emit('update-status', 'error')
}
}
@@ -893,12 +893,12 @@ const pollPrepareStatus = async () => {
// 检查是否完成
if (data.status === 'completed' || data.status === 'ready' || data.already_prepared) {
addLog('✓ 准备工作已完成')
addLog(t('log.prepareComplete'))
stopPolling()
stopProfilesPolling()
await loadPreparedData()
} else if (data.status === 'failed') {
addLog(`✗ 准备失败: ${data.error || '未知错误'}`)
addLog(t('log.prepareFailedWithError', { error: data.error || t('common.unknownError') }))
stopPolling()
stopProfilesPolling()
}
@@ -937,13 +937,13 @@ const fetchProfilesRealtime = async () => {
const latestProfile = profiles.value[currentCount - 1]
const profileName = latestProfile?.name || latestProfile?.username || `Agent_${currentCount}`
if (currentCount === 1) {
addLog(`开始生成Agent人设...`)
addLog(t('log.startGeneratingAgentProfiles'))
}
addLog(`→ Agent人设 ${currentCount}/${total}: ${profileName} (${latestProfile?.profession || '未知职业'})`)
addLog(t('log.agentProfile', { current: currentCount, total: total, name: profileName, profession: latestProfile?.profession || t('step2.unknownProfession') }))
// 如果全部生成完成
if (expectedTotal.value && currentCount >= expectedTotal.value) {
addLog(`✓ 全部 ${currentCount} 个Agent人设生成完成`)
addLog(t('log.allProfilesComplete', { count: currentCount }))
}
}
}
@@ -977,41 +977,41 @@ const fetchConfigRealtime = async () => {
if (data.generation_stage && data.generation_stage !== lastLoggedConfigStage) {
lastLoggedConfigStage = data.generation_stage
if (data.generation_stage === 'generating_profiles') {
addLog('正在生成Agent人设配置...')
addLog(t('log.generatingAgentProfileConfig'))
} else if (data.generation_stage === 'generating_config') {
addLog('正在调用LLM生成模拟配置参数...')
addLog(t('log.generatingLLMConfig'))
}
}
// 如果配置已生成
if (data.config_generated && data.config) {
simulationConfig.value = data.config
addLog('✓ 模拟配置生成完成')
addLog(t('log.configComplete'))
// 显示详细配置摘要
if (data.summary) {
addLog(` ├─ Agent数量: ${data.summary.total_agents}`)
addLog(` ├─ 模拟时长: ${data.summary.simulation_hours}小时`)
addLog(` ├─ 初始帖子: ${data.summary.initial_posts_count}`)
addLog(` ├─ 热点话题: ${data.summary.hot_topics_count}`)
addLog(` └─ 平台配置: Twitter ${data.summary.has_twitter_config ? '✓' : '✗'}, Reddit ${data.summary.has_reddit_config ? '✓' : '✗'}`)
addLog(t('log.configSummaryAgents', { count: data.summary.total_agents }))
addLog(t('log.configSummaryHours', { hours: data.summary.simulation_hours }))
addLog(t('log.configSummaryPosts', { count: data.summary.initial_posts_count }))
addLog(t('log.configSummaryTopics', { count: data.summary.hot_topics_count }))
addLog(t('log.configSummaryPlatforms', { twitter: data.summary.has_twitter_config ? '✓' : '✗', reddit: data.summary.has_reddit_config ? '✓' : '✗' }))
}
// 显示时间配置详情
if (data.config.time_config) {
const tc = data.config.time_config
addLog(`时间配置: 每轮${tc.minutes_per_round}分钟, 共${Math.floor((tc.total_simulation_hours * 60) / tc.minutes_per_round)}`)
addLog(t('log.timeConfigDetail', { minutes: tc.minutes_per_round, rounds: Math.floor((tc.total_simulation_hours * 60) / tc.minutes_per_round) }))
}
// 显示事件配置
if (data.config.event_config?.narrative_direction) {
const narrative = data.config.event_config.narrative_direction
addLog(`叙事方向: ${narrative.length > 50 ? narrative.substring(0, 50) + '...' : narrative}`)
addLog(t('log.narrativeDirection', { direction: narrative.length > 50 ? narrative.substring(0, 50) + '...' : narrative }))
}
stopConfigPolling()
phase.value = 4
addLog('✓ 环境搭建完成,可以开始模拟')
addLog(t('log.envSetupComplete'))
emit('update-status', 'completed')
}
}
@@ -1022,11 +1022,11 @@ const fetchConfigRealtime = async () => {
const loadPreparedData = async () => {
phase.value = 2
addLog('正在加载已有配置数据...')
addLog(t('log.loadingExistingConfig'))
// 最后获取一次 Profiles
await fetchProfilesRealtime()
addLog(`已加载 ${profiles.value.length} 个Agent人设`)
addLog(t('log.loadedAgentProfiles', { count: profiles.value.length }))
// 获取配置(使用实时接口)
try {
@@ -1034,26 +1034,26 @@ const loadPreparedData = async () => {
if (res.success && res.data) {
if (res.data.config_generated && res.data.config) {
simulationConfig.value = res.data.config
addLog('✓ 模拟配置加载成功')
addLog(t('log.configLoadSuccess'))
// 显示详细配置摘要
if (res.data.summary) {
addLog(` ├─ Agent数量: ${res.data.summary.total_agents}`)
addLog(` ├─ 模拟时长: ${res.data.summary.simulation_hours}小时`)
addLog(` └─ 初始帖子: ${res.data.summary.initial_posts_count}`)
addLog(t('log.configSummaryAgents', { count: res.data.summary.total_agents }))
addLog(t('log.configSummaryHours', { hours: res.data.summary.simulation_hours }))
addLog(t('log.configSummaryPostsAlt', { count: res.data.summary.initial_posts_count }))
}
addLog('✓ 环境搭建完成,可以开始模拟')
addLog(t('log.envSetupComplete'))
phase.value = 4
emit('update-status', 'completed')
} else {
// 配置尚未生成,开始轮询
addLog('配置生成中,开始轮询等待...')
addLog(t('log.configGenerating'))
startConfigPolling()
}
}
} catch (err) {
addLog(`加载配置失败: ${err.message}`)
addLog(t('log.loadConfigFailed', { error: err.message }))
emit('update-status', 'error')
}
}
@@ -1071,7 +1071,7 @@ watch(() => props.systemLogs?.length, () => {
onMounted(() => {
// 自动开始准备流程
if (props.simulationId) {
addLog('Step2 环境搭建初始化')
addLog(t('log.step2Init'))
startPrepareSimulation()
}
})