Browse Source

fix: map route list cards from waypointCount only

List API never returns waypoints[]; drop the dead array branch and
read waypointCount directly.
main
xiaosi 2 weeks ago
parent
commit
4b958aacb2
  1. 32
      src/views/TasksView/TasksView.vue

32
src/views/TasksView/TasksView.vue

@ -502,28 +502,16 @@ async function load() {
return toExecutionRecord(r, taskNames.get(r.taskId), '', video ? { id: String(video.id), status: video.status } : null) return toExecutionRecord(r, taskNames.get(r.taskId), '', video ? { id: String(video.id), status: video.status } : null)
}) })
routes.value = (routePage?.records || []).map((r, i) => {
// waypointCount waypoints[]
const count = Number(r.waypointCount ?? r.waypoint_count)
const fromList = Array.isArray(r.waypoints) ? r.waypoints.length : NaN
const waypoints = Number.isFinite(fromList)
? fromList
: (Number.isFinite(count) ? count : 0)
const distance = Array.isArray(r.waypoints) && r.waypoints.length
? `${routeDistance(r.waypoints.map((p) => ({
longitude: Number(p.longitude),
latitude: Number(p.latitude),
}))).toFixed(1)} km`
: (r.distance || '--')
return {
id: String(r.id),
name: r.name,
waypoints,
distance,
collectedAt: fmtTime(r.createdAt),
mapClass: i % 2 === 0 ? 'route-a' : 'route-c',
}
})
routes.value = (routePage?.records || []).map((r, i) => ({
id: String(r.id),
name: r.name,
// waypointCount waypoints[]
waypoints: Number(r.waypointCount) || 0,
// --
distance: '--',
collectedAt: fmtTime(r.createdAt),
mapClass: i % 2 === 0 ? 'route-a' : 'route-c',
}))
const hasActiveExecution = (execPage?.records || []).some((r) => ['pending', 'running'].includes(r.status)) const hasActiveExecution = (execPage?.records || []).some((r) => ['pending', 'running'].includes(r.status))
if (hasActiveExecution && !refreshTimer) refreshTimer = window.setInterval(load, 5000) if (hasActiveExecution && !refreshTimer) refreshTimer = window.setInterval(load, 5000)
if (!hasActiveExecution && refreshTimer) { if (!hasActiveExecution && refreshTimer) {

Loading…
Cancel
Save