Add simulation API and environment setup components
- Introduced simulation.js API for creating and managing simulations, including methods for creating, preparing, and retrieving simulation statuses. - Added Step1GraphBuild.vue and Step2EnvSetup.vue components to facilitate the graph building and environment setup processes, enhancing user interaction and workflow. - Updated MainView.vue to integrate new components and manage the simulation workflow, including step indicators and navigation between steps. - Created SimulationView.vue for displaying simulation details and managing the simulation environment, improving overall user experience and functionality.
This commit is contained in:
@@ -159,10 +159,11 @@
|
||||
<p class="description">图谱构建已完成,请进入下一步进行模拟环境搭建</p>
|
||||
<button
|
||||
class="action-btn"
|
||||
:disabled="currentPhase < 2"
|
||||
@click="$emit('next-step')"
|
||||
:disabled="currentPhase < 2 || creatingSimulation"
|
||||
@click="handleEnterEnvSetup"
|
||||
>
|
||||
进入环境搭建 ➝
|
||||
<span v-if="creatingSimulation" class="spinner-sm"></span>
|
||||
{{ creatingSimulation ? '创建中...' : '进入环境搭建 ➝' }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
@@ -186,6 +187,10 @@
|
||||
|
||||
<script setup>
|
||||
import { computed, ref, watch, nextTick } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { createSimulation } from '../api/simulation'
|
||||
|
||||
const router = useRouter()
|
||||
|
||||
const props = defineProps({
|
||||
currentPhase: { type: Number, default: 0 },
|
||||
@@ -200,6 +205,42 @@ defineEmits(['next-step'])
|
||||
|
||||
const selectedOntologyItem = ref(null)
|
||||
const logContent = ref(null)
|
||||
const creatingSimulation = ref(false)
|
||||
|
||||
// 进入环境搭建 - 创建 simulation 并跳转
|
||||
const handleEnterEnvSetup = async () => {
|
||||
if (!props.projectData?.project_id || !props.projectData?.graph_id) {
|
||||
console.error('缺少项目或图谱信息')
|
||||
return
|
||||
}
|
||||
|
||||
creatingSimulation.value = true
|
||||
|
||||
try {
|
||||
const res = await createSimulation({
|
||||
project_id: props.projectData.project_id,
|
||||
graph_id: props.projectData.graph_id,
|
||||
enable_twitter: true,
|
||||
enable_reddit: true
|
||||
})
|
||||
|
||||
if (res.success && res.data?.simulation_id) {
|
||||
// 跳转到 simulation 页面
|
||||
router.push({
|
||||
name: 'Simulation',
|
||||
params: { simulationId: res.data.simulation_id }
|
||||
})
|
||||
} else {
|
||||
console.error('创建模拟失败:', res.error)
|
||||
alert('创建模拟失败: ' + (res.error || '未知错误'))
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('创建模拟异常:', err)
|
||||
alert('创建模拟异常: ' + err.message)
|
||||
} finally {
|
||||
creatingSimulation.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const selectOntologyItem = (item, type) => {
|
||||
selectedOntologyItem.value = { ...item, itemType: type }
|
||||
1042
frontend/src/components/Step2EnvSetup.vue
Normal file
1042
frontend/src/components/Step2EnvSetup.vue
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user