feat(i18n): replace hardcoded Chinese in frontend addLog() messages
This commit is contained in:
@@ -73,7 +73,9 @@ import Step2EnvSetup from '../components/Step2EnvSetup.vue'
|
||||
import { getProject, getGraphData } from '../api/graph'
|
||||
import { getSimulation, stopSimulation, getEnvStatus, closeSimulationEnv } from '../api/simulation'
|
||||
import LanguageSwitcher from '../components/LanguageSwitcher.vue'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
|
||||
const { t } = useI18n()
|
||||
const route = useRoute()
|
||||
const router = useRouter()
|
||||
|
||||
@@ -149,13 +151,13 @@ const handleGoBack = () => {
|
||||
}
|
||||
|
||||
const handleNextStep = (params = {}) => {
|
||||
addLog('进入 Step 3: 开始模拟')
|
||||
|
||||
addLog(t('log.enterStep3'))
|
||||
|
||||
// 记录模拟轮数配置
|
||||
if (params.maxRounds) {
|
||||
addLog(`自定义模拟轮数: ${params.maxRounds} 轮`)
|
||||
addLog(t('log.customRoundsConfig', { rounds: params.maxRounds }))
|
||||
} else {
|
||||
addLog('使用自动配置的模拟轮数')
|
||||
addLog(t('log.useAutoRounds'))
|
||||
}
|
||||
|
||||
// 构建路由参数
|
||||
@@ -187,7 +189,7 @@ const checkAndStopRunningSimulation = async () => {
|
||||
const envStatusRes = await getEnvStatus({ simulation_id: currentSimulationId.value })
|
||||
|
||||
if (envStatusRes.success && envStatusRes.data?.env_alive) {
|
||||
addLog('检测到模拟环境正在运行,正在关闭...')
|
||||
addLog(t('log.detectedSimEnvRunning'))
|
||||
|
||||
// 尝试优雅关闭模拟环境
|
||||
try {
|
||||
@@ -197,14 +199,14 @@ const checkAndStopRunningSimulation = async () => {
|
||||
})
|
||||
|
||||
if (closeRes.success) {
|
||||
addLog('✓ 模拟环境已关闭')
|
||||
addLog(t('log.simEnvClosed'))
|
||||
} else {
|
||||
addLog(`关闭模拟环境失败: ${closeRes.error || '未知错误'}`)
|
||||
addLog(t('log.closeSimEnvFailedWithError', { error: closeRes.error || t('common.unknownError') }))
|
||||
// 如果优雅关闭失败,尝试强制停止
|
||||
await forceStopSimulation()
|
||||
}
|
||||
} catch (closeErr) {
|
||||
addLog(`关闭模拟环境异常: ${closeErr.message}`)
|
||||
addLog(t('log.closeSimEnvException', { error: closeErr.message }))
|
||||
// 如果优雅关闭异常,尝试强制停止
|
||||
await forceStopSimulation()
|
||||
}
|
||||
@@ -212,7 +214,7 @@ const checkAndStopRunningSimulation = async () => {
|
||||
// 环境未运行,但可能进程还在,检查模拟状态
|
||||
const simRes = await getSimulation(currentSimulationId.value)
|
||||
if (simRes.success && simRes.data?.status === 'running') {
|
||||
addLog('检测到模拟状态为运行中,正在停止...')
|
||||
addLog(t('log.detectedSimRunning'))
|
||||
await forceStopSimulation()
|
||||
}
|
||||
}
|
||||
@@ -229,30 +231,30 @@ const forceStopSimulation = async () => {
|
||||
try {
|
||||
const stopRes = await stopSimulation({ simulation_id: currentSimulationId.value })
|
||||
if (stopRes.success) {
|
||||
addLog('✓ 模拟已强制停止')
|
||||
addLog(t('log.simForceStopSuccess'))
|
||||
} else {
|
||||
addLog(`强制停止模拟失败: ${stopRes.error || '未知错误'}`)
|
||||
addLog(t('log.forceStopSimFailed', { error: stopRes.error || t('common.unknownError') }))
|
||||
}
|
||||
} catch (err) {
|
||||
addLog(`强制停止模拟异常: ${err.message}`)
|
||||
addLog(t('log.forceStopSimException', { error: err.message }))
|
||||
}
|
||||
}
|
||||
|
||||
const loadSimulationData = async () => {
|
||||
try {
|
||||
addLog(`加载模拟数据: ${currentSimulationId.value}`)
|
||||
|
||||
addLog(t('log.loadingSimData', { id: currentSimulationId.value }))
|
||||
|
||||
// 获取 simulation 信息
|
||||
const simRes = await getSimulation(currentSimulationId.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) {
|
||||
@@ -261,10 +263,10 @@ const loadSimulationData = async () => {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
addLog(`加载模拟数据失败: ${simRes.error || '未知错误'}`)
|
||||
addLog(t('log.loadSimDataFailed', { error: simRes.error || t('common.unknownError') }))
|
||||
}
|
||||
} catch (err) {
|
||||
addLog(`加载异常: ${err.message}`)
|
||||
addLog(t('log.loadException', { error: err.message }))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -274,10 +276,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
|
||||
}
|
||||
@@ -290,7 +292,7 @@ const refreshGraph = () => {
|
||||
}
|
||||
|
||||
onMounted(async () => {
|
||||
addLog('SimulationView 初始化')
|
||||
addLog(t('log.simViewInit'))
|
||||
|
||||
// 检查并关闭正在运行的模拟(用户从 Step 3 返回时)
|
||||
await checkAndStopRunningSimulation()
|
||||
|
||||
Reference in New Issue
Block a user