Add new JSON data file and enhance simulation management features

- Introduced a new JSON data file containing detailed actions and quotes related to the 武大声誉修复基金 initiative.
- Updated the OasisProfileGenerator to ensure compatibility with the new JSON format, emphasizing the inclusion of user_id.
- Modified simulation management to support independent tracking of Twitter and Reddit platforms, including completion status and round information.
- Enhanced the SimulationRunner to accurately reflect the completion state of each platform and added checks for overall simulation completion.
- Improved the GraphPanel and Step3Simulation components to provide real-time updates and better user feedback during simulations.
This commit is contained in:
666ghj
2025-12-12 16:13:08 +08:00
parent f8a58819fa
commit 0577ecdae8
7 changed files with 4628 additions and 928 deletions

View File

@@ -41,6 +41,7 @@
:graphData="graphData"
:loading="graphLoading"
:currentPhase="3"
:isSimulating="isSimulating"
@refresh="refreshGraph"
@toggle-maximize="toggleMaximize('graph')"
/>
@@ -65,7 +66,7 @@
</template>
<script setup>
import { ref, computed, onMounted } from 'vue'
import { ref, computed, onMounted, onUnmounted, watch } from 'vue'
import { useRoute, useRouter } from 'vue-router'
import GraphPanel from '../components/GraphPanel.vue'
import Step3Simulation from '../components/Step3Simulation.vue'
@@ -117,6 +118,8 @@ const statusText = computed(() => {
return 'Running'
})
const isSimulating = computed(() => currentStatus.value === 'processing')
// --- Helpers ---
const addLog = (msg) => {
const time = new Date().toLocaleTimeString('en-US', { hour12: false, hour: '2-digit', minute: '2-digit', second: '2-digit' }) + '.' + new Date().getMilliseconds().toString().padStart(3, '0')
@@ -182,12 +185,19 @@ const loadSimulationData = async () => {
}
const loadGraph = async (graphId) => {
graphLoading.value = true
// 当正在模拟时,自动刷新不显示全屏 loading以免闪烁
// 手动刷新或初始加载时显示 loading
if (!isSimulating.value) {
graphLoading.value = true
}
try {
const res = await getGraphData(graphId)
if (res.success) {
graphData.value = res.data
addLog('图谱数据加载成功')
if (!isSimulating.value) {
addLog('图谱数据加载成功')
}
}
} catch (err) {
addLog(`图谱加载失败: ${err.message}`)
@@ -202,6 +212,32 @@ const refreshGraph = () => {
}
}
// --- Auto Refresh Logic ---
let graphRefreshTimer = null
const startGraphRefresh = () => {
if (graphRefreshTimer) return
addLog('开启图谱实时刷新 (30s)')
// 立即刷新一次然后每30秒刷新
graphRefreshTimer = setInterval(refreshGraph, 30000)
}
const stopGraphRefresh = () => {
if (graphRefreshTimer) {
clearInterval(graphRefreshTimer)
graphRefreshTimer = null
addLog('停止图谱实时刷新')
}
}
watch(isSimulating, (newValue) => {
if (newValue) {
startGraphRefresh()
} else {
stopGraphRefresh()
}
}, { immediate: true })
onMounted(() => {
addLog('SimulationRunView 初始化')
@@ -212,6 +248,10 @@ onMounted(() => {
loadSimulationData()
})
onUnmounted(() => {
stopGraphRefresh()
})
</script>
<style scoped>