fix: 修复历史记录为空问题

refactor
Lxy 6 days ago
parent b43fa24165
commit 76a98d3b95

Binary file not shown.

@ -29,11 +29,13 @@
<script setup>
import { ref, onMounted } from 'vue'
import { useRouter } from 'vue-router'
import { useAuthStore } from '../stores/auth'
import { useItineraryStore } from '../stores/itinerary'
import { trackPlanLoad } from '../services/statsService'
const emit = defineEmits(['close', 'load'])
const router = useRouter()
const authStore = useAuthStore()
const itineraryStore = useItineraryStore()
@ -92,8 +94,12 @@ async function loadPlan(plan) {
const planData = data.plan.data
if (planData.points) {
itineraryStore.loadFromAI({ points: planData.points })
itineraryStore.setPhase('workbench')
trackPlanLoad(plan.id)
emit('load', plan)
//
router.push('/')
}
}
} catch (err) {

@ -226,10 +226,14 @@
<script setup>
import { ref, computed, onMounted } from 'vue'
import { useItineraryStore } from '../stores/itinerary'
import { useAuthStore } from '../stores/auth'
import { trackPlanCreate, trackSchemeSelect } from '../services/statsService'
import { quickPlan } from '../services/aiService'
import { exportToMarkdown } from '../services/exportService'
const store = useItineraryStore()
const authStore = useAuthStore()
const API_BASE = 'http://localhost:3001/api'
const allSchemes = computed(() => store.quickSchemes)
const historySchemes = computed(() => store.historySchemeGroups)
@ -419,12 +423,51 @@ function selectScheme(index) {
store.saveSchemesToStore(allSchemes.value, historySchemes.value)
store.setActiveSchemeIndex(index)
//
savePlanToBackend(scheme)
// 使
const savedScheme = store.quickSchemes[index]
console.log('[selectScheme] 深拷贝后的方案 points 数量:', savedScheme?.points?.length)
store.loadFromAI(savedScheme)
store.setPhase('workbench')
//
trackSchemeSelect(scheme.name, index)
}
async function savePlanToBackend(scheme) {
try {
const headers = { 'Content-Type': 'application/json' }
if (authStore.token) {
headers['Authorization'] = `Bearer ${authStore.token}`
}
const body = {
name: scheme.name,
description: scheme.route,
data: scheme,
guestId: authStore.guestId || undefined
}
const res = await fetch(`${API_BASE}/plans`, {
method: 'POST',
headers,
body: JSON.stringify(body)
})
if (res.ok) {
const data = await res.json()
console.log('[savePlan] 方案保存成功:', data.id)
trackPlanCreate(scheme.name, 'quick')
} else {
const error = await res.json()
console.error('[savePlan] 保存失败:', error)
}
} catch (err) {
console.error('[savePlan] 保存异常:', err)
}
}
function openPreview(index) {

Loading…
Cancel
Save