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

View File

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

View File

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

View File

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