feat(history): use listProjects API for project recovery in home page

Replace getSimulationHistory (simulation API) with listProjects (graph API)
and adapt all template references from simulation_id/report_id fields to
project_id/graph_id fields matching the new project data model.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Ubuntu 2026-05-03 01:31:53 +00:00
parent 1eae54346f
commit 607a2640e1
1 changed files with 20 additions and 25 deletions

View File

@ -21,7 +21,7 @@
<div v-if="projects.length > 0" class="cards-container" :class="{ expanded: isExpanded }" :style="containerStyle"> <div v-if="projects.length > 0" class="cards-container" :class="{ expanded: isExpanded }" :style="containerStyle">
<div <div
v-for="(project, index) in projects" v-for="(project, index) in projects"
:key="project.simulation_id" :key="project.project_id"
class="project-card" class="project-card"
:class="{ expanded: isExpanded, hovering: hoveringCard === index }" :class="{ expanded: isExpanded, hovering: hoveringCard === index }"
:style="getCardStyle(index)" :style="getCardStyle(index)"
@ -31,7 +31,7 @@
> >
<!-- 卡片头部simulation_id 功能可用状态 --> <!-- 卡片头部simulation_id 功能可用状态 -->
<div class="card-header"> <div class="card-header">
<span class="card-id">{{ formatSimulationId(project.simulation_id) }}</span> <span class="card-id">{{ project.name || (project.project_id || '').slice(0, 8) }}</span>
<div class="card-status-icons"> <div class="card-status-icons">
<span <span
class="status-icon" class="status-icon"
@ -39,12 +39,12 @@
:title="$t('history.graphBuild')" :title="$t('history.graphBuild')"
></span> ></span>
<span <span
class="status-icon available" class="status-icon"
:class="{ available: project.graph_id, unavailable: !project.graph_id }"
:title="$t('history.envSetup')" :title="$t('history.envSetup')"
></span> ></span>
<span <span
class="status-icon" class="status-icon unavailable"
:class="{ available: project.report_id, unavailable: !project.report_id }"
:title="$t('history.analysisReport')" :title="$t('history.analysisReport')"
></span> ></span>
</div> </div>
@ -113,7 +113,7 @@
<!-- 弹窗头部 --> <!-- 弹窗头部 -->
<div class="modal-header"> <div class="modal-header">
<div class="modal-title-section"> <div class="modal-title-section">
<span class="modal-id">{{ formatSimulationId(selectedProject.simulation_id) }}</span> <span class="modal-id">{{ selectedProject.name || (selectedProject.project_id || '').slice(0, 8) }}</span>
<span class="modal-progress" :class="getProgressClass(selectedProject)"> <span class="modal-progress" :class="getProgressClass(selectedProject)">
<span class="status-dot"></span> {{ formatRounds(selectedProject) }} <span class="status-dot"></span> {{ formatRounds(selectedProject) }}
</span> </span>
@ -164,6 +164,7 @@
<button <button
class="modal-btn btn-simulation" class="modal-btn btn-simulation"
@click="goToSimulation" @click="goToSimulation"
:disabled="!selectedProject.graph_id"
> >
<span class="btn-step">Step2</span> <span class="btn-step">Step2</span>
<span class="btn-icon"></span> <span class="btn-icon"></span>
@ -172,7 +173,7 @@
<button <button
class="modal-btn btn-report" class="modal-btn btn-report"
@click="goToReport" @click="goToReport"
:disabled="!selectedProject.report_id" :disabled="true"
> >
<span class="btn-step">Step4</span> <span class="btn-step">Step4</span>
<span class="btn-icon"></span> <span class="btn-icon"></span>
@ -194,7 +195,7 @@
import { ref, computed, onMounted, onUnmounted, onActivated, watch, nextTick } from 'vue' import { ref, computed, onMounted, onUnmounted, onActivated, watch, nextTick } from 'vue'
import { useRouter, useRoute } from 'vue-router' import { useRouter, useRoute } from 'vue-router'
import { useI18n } from 'vue-i18n' import { useI18n } from 'vue-i18n'
import { getSimulationHistory } from '../api/simulation' import { listProjects } from '../api/graph'
const router = useRouter() const router = useRouter()
const route = useRoute() const route = useRoute()
@ -416,10 +417,10 @@ const goToProject = () => {
// Simulation // Simulation
const goToSimulation = () => { const goToSimulation = () => {
if (selectedProject.value?.simulation_id) { if (selectedProject.value?.graph_id) {
router.push({ router.push({
name: 'Simulation', name: 'Process',
params: { simulationId: selectedProject.value.simulation_id } params: { projectId: selectedProject.value.project_id }
}) })
closeModal() closeModal()
} }
@ -427,20 +428,14 @@ const goToSimulation = () => {
// Report // Report
const goToReport = () => { const goToReport = () => {
if (selectedProject.value?.report_id) { // Report not yet implemented in F1-1
router.push({
name: 'Report',
params: { reportId: selectedProject.value.report_id }
})
closeModal()
}
} }
// //
const loadHistory = async () => { const loadHistory = async () => {
try { try {
loading.value = true loading.value = true
const response = await getSimulationHistory(20) const response = await listProjects(20)
if (response.success) { if (response.success) {
projects.value = response.data || [] projects.value = response.data || []
} }