diff --git a/frontend/src/views/SimulationRunView.vue b/frontend/src/views/SimulationRunView.vue index 894487e..20c247a 100644 --- a/frontend/src/views/SimulationRunView.vue +++ b/frontend/src/views/SimulationRunView.vue @@ -188,8 +188,8 @@ const handleGoBack = async () => { addLog(`Failed to check simulation status: ${err.message}`) } - // 返回到 Step 2 (环境搭建) - router.push({ name: 'Simulation', params: { simulationId: currentSimulationId.value } }) + // 返回到 Step 2 (环境搭建), with flag so Step 2 knows to stop the sim + router.push({ name: 'Simulation', params: { simulationId: currentSimulationId.value }, query: { fromStep3: '1' } }) } const handleNextStep = () => { diff --git a/frontend/src/views/SimulationView.vue b/frontend/src/views/SimulationView.vue index ec335a9..98475ad 100644 --- a/frontend/src/views/SimulationView.vue +++ b/frontend/src/views/SimulationView.vue @@ -288,10 +288,15 @@ const refreshGraph = () => { onMounted(async () => { addLog('SimulationView initialized') - - // 检查并关闭正在运行的模拟(用户从 Step 3 返回时) - await checkAndStopRunningSimulation() - + + // Only stop running simulation if user explicitly navigated back from Step 3 + // (indicated by 'fromStep3' query param), not on page refresh + if (route.query.fromStep3) { + await checkAndStopRunningSimulation() + // Clean up the query param + router.replace({ ...route, query: {} }) + } + // 加载模拟数据 loadSimulationData() })