feat(i18n): replace remaining hardcoded Chinese in frontend addLog calls

This commit is contained in:
ghostubborn
2026-04-01 17:21:55 +08:00
parent 0e55e4cf6b
commit 3a8451c119
5 changed files with 70 additions and 66 deletions

View File

@@ -22,7 +22,7 @@
<span class="stat-value mono">{{ runStatus.twitter_current_round || 0 }}<span class="stat-total">/{{ runStatus.total_rounds || maxRounds || '-' }}</span></span>
</span>
<span class="stat">
<span class="stat-label">Elapsed Time</span>
<span class="stat-label">TIME</span>
<span class="stat-value mono">{{ twitterElapsedTime }}</span>
</span>
<span class="stat">
@@ -63,7 +63,7 @@
<span class="stat-value mono">{{ runStatus.reddit_current_round || 0 }}<span class="stat-total">/{{ runStatus.total_rounds || maxRounds || '-' }}</span></span>
</span>
<span class="stat">
<span class="stat-label">Elapsed Time</span>
<span class="stat-label">TIME</span>
<span class="stat-value mono">{{ redditElapsedTime }}</span>
</span>
<span class="stat">
@@ -382,16 +382,16 @@ const resetAllState = () => {
// 启动模拟
const doStartSimulation = async () => {
if (!props.simulationId) {
addLog('错误缺少 simulationId')
addLog(t('log.errorMissingSimId'))
return
}
// 先重置所有状态,确保不会受到上一次模拟的影响
resetAllState()
isStarting.value = true
startError.value = null
addLog('正在启动双平台并行模拟...')
addLog(t('log.startingDualSim'))
emit('update-status', 'processing')
try {
@@ -404,18 +404,18 @@ const doStartSimulation = async () => {
if (props.maxRounds) {
params.max_rounds = props.maxRounds
addLog(`设置最大模拟轮数: ${props.maxRounds}`)
addLog(t('log.setMaxRounds', { rounds: props.maxRounds }))
}
addLog('已开启动态图谱更新模式')
addLog(t('log.graphMemoryUpdateEnabled'))
const res = await startSimulation(params)
if (res.success && res.data) {
if (res.data.force_restarted) {
addLog(' 已清理旧的模拟日志重新开始模拟')
addLog(t('log.oldSimCleared'))
}
addLog(' 模拟引擎启动成功')
addLog(t('log.engineStarted'))
addLog(` ├─ PID: ${res.data.process_pid || '-'}`)
phase.value = 1
@@ -425,12 +425,12 @@ const doStartSimulation = async () => {
startDetailPolling()
} else {
startError.value = res.error || '启动失败'
addLog(`✗ 启动失败: ${res.error || '未知错误'}`)
addLog(t('log.startFailed', { error: res.error || t('common.unknownError') }))
emit('update-status', 'error')
}
} catch (err) {
startError.value = err.message
addLog(`✗ 启动异常: ${err.message}`)
addLog(t('log.startException', { error: err.message }))
emit('update-status', 'error')
} finally {
isStarting.value = false
@@ -442,21 +442,21 @@ const handleStopSimulation = async () => {
if (!props.simulationId) return
isStopping.value = true
addLog('正在停止模拟...')
addLog(t('log.stoppingSim'))
try {
const res = await stopSimulation({ simulation_id: props.simulationId })
if (res.success) {
addLog(' 模拟已停止')
addLog(t('log.simStoppedSuccess'))
phase.value = 2
stopPolling()
emit('update-status', 'completed')
} else {
addLog(`停止失败: ${res.error || '未知错误'}`)
addLog(t('log.stopFailed', { error: res.error || t('common.unknownError') }))
}
} catch (err) {
addLog(`停止异常: ${err.message}`)
addLog(t('log.stopException', { error: err.message }))
} finally {
isStopping.value = false
}
@@ -520,9 +520,9 @@ const fetchRunStatus = async () => {
if (isCompleted || platformsCompleted) {
if (platformsCompleted && !isCompleted) {
addLog(' 检测到所有平台模拟已结束')
addLog(t('log.allPlatformsCompleted'))
}
addLog(' 模拟已完成')
addLog(t('log.simCompleted'))
phase.value = 2
stopPolling()
emit('update-status', 'completed')
@@ -643,17 +643,17 @@ const formatActionTime = (timestamp) => {
const handleNextStep = async () => {
if (!props.simulationId) {
addLog('错误缺少 simulationId')
addLog(t('log.errorMissingSimId'))
return
}
if (isGeneratingReport.value) {
addLog('报告生成请求已发送请稍候...')
addLog(t('log.reportRequestSent'))
return
}
isGeneratingReport.value = true
addLog('正在启动报告生成...')
addLog(t('log.startingReportGen'))
try {
const res = await generateReport({
@@ -663,16 +663,16 @@ const handleNextStep = async () => {
if (res.success && res.data) {
const reportId = res.data.report_id
addLog(`✓ 报告生成任务已启动: ${reportId}`)
addLog(t('log.reportGenTaskStarted', { reportId }))
// 跳转到报告页面
router.push({ name: 'Report', params: { reportId } })
} else {
addLog(`✗ 启动报告生成失败: ${res.error || '未知错误'}`)
addLog(t('log.reportGenFailed', { error: res.error || t('common.unknownError') }))
isGeneratingReport.value = false
}
} catch (err) {
addLog(`✗ 启动报告生成异常: ${err.message}`)
addLog(t('log.reportGenException', { error: err.message }))
isGeneratingReport.value = false
}
}
@@ -688,7 +688,7 @@ watch(() => props.systemLogs?.length, () => {
})
onMounted(() => {
addLog('Step3 模拟运行初始化')
addLog(t('log.step3Init'))
if (props.simulationId) {
doStartSimulation()
}

View File

@@ -538,7 +538,7 @@ const selectAgent = (agent, idx) => {
// 恢复该 Agent 的对话记录
chatHistory.value = chatHistoryCache.value[`agent_${idx}`] || []
addLog(`选择对话对象: ${agent.username}`)
addLog(t('log.selectChatTarget', { name: agent.username }))
}
const formatTime = (timestamp) => {
@@ -665,7 +665,7 @@ const sendMessage = async () => {
await sendToAgent(message)
}
} catch (err) {
addLog(`发送失败: ${err.message}`)
addLog(t('log.sendFailed', { error: err.message }))
chatHistory.value.push({
role: 'assistant',
content: t('step5.errorOccurred', { error: err.message }),
@@ -680,7 +680,7 @@ const sendMessage = async () => {
}
const sendToReportAgent = async (message) => {
addLog(`Report Agent 发送: ${message.substring(0, 50)}...`)
addLog(t('log.sendToReportAgent', { message: message.substring(0, 50) }))
// Build chat history for API
const historyForApi = chatHistory.value
@@ -703,7 +703,7 @@ const sendToReportAgent = async (message) => {
content: res.data.response || res.data.answer || t('step5.noResponse'),
timestamp: new Date().toISOString()
})
addLog('Report Agent 已回复')
addLog(t('log.reportAgentReplied'))
} else {
throw new Error(res.error || t('step5.requestFailed'))
}
@@ -714,7 +714,7 @@ const sendToAgent = async (message) => {
throw new Error(t('step5.selectAgentFirst'))
}
addLog(`${selectedAgent.value.username} 发送: ${message.substring(0, 50)}...`)
addLog(t('log.sendToAgent', { name: selectedAgent.value.username, message: message.substring(0, 50) }))
// Build prompt with chat history
let prompt = message
@@ -764,7 +764,7 @@ const sendToAgent = async (message) => {
content: responseContent,
timestamp: new Date().toISOString()
})
addLog(`${selectedAgent.value.username} 已回复`)
addLog(t('log.agentReplied', { name: selectedAgent.value.username }))
} else {
throw new Error(t('step5.noResponse'))
}
@@ -806,7 +806,7 @@ const submitSurvey = async () => {
if (selectedAgents.value.size === 0 || !surveyQuestion.value.trim()) return
isSurveying.value = true
addLog(`发送问卷给 ${selectedAgents.value.size} 个对象...`)
addLog(t('log.sendSurvey', { count: selectedAgents.value.size }))
try {
const interviews = Array.from(selectedAgents.value).map(idx => ({
@@ -860,12 +860,12 @@ const submitSurvey = async () => {
}
surveyResults.value = surveyResultsList
addLog(`收到 ${surveyResults.value.length} 条回复`)
addLog(t('log.receivedReplies', { count: surveyResults.value.length }))
} else {
throw new Error(res.error || t('step5.requestFailed'))
}
} catch (err) {
addLog(`问卷发送失败: ${err.message}`)
addLog(t('log.surveySendFailed', { error: err.message }))
} finally {
isSurveying.value = false
}
@@ -876,7 +876,7 @@ const loadReportData = async () => {
if (!props.reportId) return
try {
addLog(`加载报告数据: ${props.reportId}`)
addLog(t('log.loadReportData', { id: props.reportId }))
// Get report info
const reportRes = await getReport(props.reportId)
@@ -885,7 +885,7 @@ const loadReportData = async () => {
await loadAgentLogs()
}
} catch (err) {
addLog(`加载报告失败: ${err.message}`)
addLog(t('log.loadReportFailed', { error: err.message }))
}
}
@@ -907,10 +907,10 @@ const loadAgentLogs = async () => {
}
})
addLog('报告数据加载完成')
addLog(t('log.reportDataLoaded'))
}
} catch (err) {
addLog(`加载报告日志失败: ${err.message}`)
addLog(t('log.loadReportLogFailed', { error: err.message }))
}
}
@@ -921,10 +921,10 @@ const loadProfiles = async () => {
const res = await getSimulationProfilesRealtime(props.simulationId, 'reddit')
if (res.success && res.data) {
profiles.value = res.data.profiles || []
addLog(`加载了 ${profiles.value.length} 个模拟个体`)
addLog(t('log.loadedProfiles', { count: profiles.value.length }))
}
} catch (err) {
addLog(`加载模拟个体失败: ${err.message}`)
addLog(t('log.loadProfilesFailed', { error: err.message }))
}
}
@@ -938,7 +938,7 @@ const handleClickOutside = (e) => {
// Lifecycle
onMounted(() => {
addLog('Step5 深度互动初始化')
addLog(t('log.step5Init'))
loadReportData()
loadProfiles()
document.addEventListener('click', handleClickOutside)

View File

@@ -66,6 +66,7 @@
<script setup>
import { ref, computed, onMounted, watch } from 'vue'
import { useRoute, useRouter } from 'vue-router'
import { useI18n } from 'vue-i18n'
import GraphPanel from '../components/GraphPanel.vue'
import Step5Interaction from '../components/Step5Interaction.vue'
import { getProject, getGraphData } from '../api/graph'
@@ -75,6 +76,7 @@ import LanguageSwitcher from '../components/LanguageSwitcher.vue'
const route = useRoute()
const router = useRouter()
const { t } = useI18n()
// Props
const props = defineProps({
@@ -143,27 +145,27 @@ const toggleMaximize = (target) => {
// --- Data Logic ---
const loadReportData = async () => {
try {
addLog(`加载报告数据: ${currentReportId.value}`)
addLog(t('log.loadReportData', { id: currentReportId.value }))
// 获取 report 信息以获取 simulation_id
const reportRes = await getReport(currentReportId.value)
if (reportRes.success && reportRes.data) {
const reportData = reportRes.data
simulationId.value = reportData.simulation_id
if (simulationId.value) {
// 获取 simulation 信息
const simRes = await getSimulation(simulationId.value)
if (simRes.success && simRes.data) {
const simData = simRes.data
// 获取 project 信息
if (simData.project_id) {
const projRes = await getProject(simData.project_id)
if (projRes.success && projRes.data) {
projectData.value = projRes.data
addLog(`项目加载成功: ${projRes.data.project_id}`)
addLog(t('log.projectLoadSuccess', { id: projRes.data.project_id }))
// 获取 graph 数据
if (projRes.data.graph_id) {
await loadGraph(projRes.data.graph_id)
@@ -173,10 +175,10 @@ const loadReportData = async () => {
}
}
} else {
addLog(`获取报告信息失败: ${reportRes.error || '未知错误'}`)
addLog(t('log.getReportInfoFailed', { error: reportRes.error || t('common.unknownError') }))
}
} catch (err) {
addLog(`加载异常: ${err.message}`)
addLog(t('log.loadException', { error: err.message }))
}
}
@@ -187,10 +189,10 @@ const loadGraph = async (graphId) => {
const res = await getGraphData(graphId)
if (res.success) {
graphData.value = res.data
addLog('图谱数据加载成功')
addLog(t('log.graphDataLoadSuccess'))
}
} catch (err) {
addLog(`图谱加载失败: ${err.message}`)
addLog(t('log.graphLoadFailed', { error: err.message }))
} finally {
graphLoading.value = false
}
@@ -211,7 +213,7 @@ watch(() => route.params.reportId, (newId) => {
}, { immediate: true })
onMounted(() => {
addLog('InteractionView 初始化')
addLog(t('log.interactionViewInit'))
loadReportData()
})
</script>

View File

@@ -164,11 +164,11 @@ const toggleMaximize = (target) => {
const handleNextStep = (params = {}) => {
if (currentStep.value < 5) {
currentStep.value++
addLog(`进入 Step ${currentStep.value}: ${stepNames.value[currentStep.value - 1]}`)
addLog(t('log.enterStep', { step: currentStep.value, name: stepNames.value[currentStep.value - 1] }))
// 如果是从 Step 2 进入 Step 3记录模拟轮数配置
if (currentStep.value === 3 && params.maxRounds) {
addLog(`自定义模拟轮数: ${params.maxRounds}`)
addLog(t('log.customSimRounds', { rounds: params.maxRounds }))
}
}
}
@@ -176,7 +176,7 @@ const handleNextStep = (params = {}) => {
const handleGoBack = () => {
if (currentStep.value > 1) {
currentStep.value--
addLog(`返回 Step ${currentStep.value}: ${stepNames.value[currentStep.value - 1]}`)
addLog(t('log.returnToStep', { step: currentStep.value, name: stepNames.value[currentStep.value - 1] }))
}
}

View File

@@ -66,6 +66,7 @@
<script setup>
import { ref, computed, onMounted, watch } from 'vue'
import { useRoute, useRouter } from 'vue-router'
import { useI18n } from 'vue-i18n'
import GraphPanel from '../components/GraphPanel.vue'
import Step4Report from '../components/Step4Report.vue'
import { getProject, getGraphData } from '../api/graph'
@@ -75,6 +76,7 @@ import LanguageSwitcher from '../components/LanguageSwitcher.vue'
const route = useRoute()
const router = useRouter()
const { t } = useI18n()
// Props
const props = defineProps({
@@ -142,27 +144,27 @@ const toggleMaximize = (target) => {
// --- Data Logic ---
const loadReportData = async () => {
try {
addLog(`加载报告数据: ${currentReportId.value}`)
addLog(t('log.loadReportData', { id: currentReportId.value }))
// 获取 report 信息以获取 simulation_id
const reportRes = await getReport(currentReportId.value)
if (reportRes.success && reportRes.data) {
const reportData = reportRes.data
simulationId.value = reportData.simulation_id
if (simulationId.value) {
// 获取 simulation 信息
const simRes = await getSimulation(simulationId.value)
if (simRes.success && simRes.data) {
const simData = simRes.data
// 获取 project 信息
if (simData.project_id) {
const projRes = await getProject(simData.project_id)
if (projRes.success && projRes.data) {
projectData.value = projRes.data
addLog(`项目加载成功: ${projRes.data.project_id}`)
addLog(t('log.projectLoadSuccess', { id: projRes.data.project_id }))
// 获取 graph 数据
if (projRes.data.graph_id) {
await loadGraph(projRes.data.graph_id)
@@ -172,10 +174,10 @@ const loadReportData = async () => {
}
}
} else {
addLog(`获取报告信息失败: ${reportRes.error || '未知错误'}`)
addLog(t('log.getReportInfoFailed', { error: reportRes.error || t('common.unknownError') }))
}
} catch (err) {
addLog(`加载异常: ${err.message}`)
addLog(t('log.loadException', { error: err.message }))
}
}
@@ -186,10 +188,10 @@ const loadGraph = async (graphId) => {
const res = await getGraphData(graphId)
if (res.success) {
graphData.value = res.data
addLog('图谱数据加载成功')
addLog(t('log.graphDataLoadSuccess'))
}
} catch (err) {
addLog(`图谱加载失败: ${err.message}`)
addLog(t('log.graphLoadFailed', { error: err.message }))
} finally {
graphLoading.value = false
}
@@ -210,7 +212,7 @@ watch(() => route.params.reportId, (newId) => {
}, { immediate: true })
onMounted(() => {
addLog('ReportView 初始化')
addLog(t('log.reportViewInit'))
loadReportData()
})
</script>