diff --git a/backend/internal/handlers/stock.go b/backend/internal/handlers/stock.go index b941b52..c403111 100644 --- a/backend/internal/handlers/stock.go +++ b/backend/internal/handlers/stock.go @@ -139,11 +139,7 @@ func (h *StockHandler) SyncStatus(c *gin.Context) { c.JSON(http.StatusInternalServerError, gin.H{"success": false, "error": "查询同步状态失败"}) return } - if job == nil { - c.JSON(http.StatusOK, gin.H{"success": true, "data": nil}) - return - } - c.JSON(http.StatusOK, gin.H{"success": true, "data": job}) + c.JSON(http.StatusOK, job) } // TriggerSync 手动触发同步(管理员)。 diff --git a/frontend/src/components/StockOverview.tsx b/frontend/src/components/StockOverview.tsx index c16f7fa..9fdc3d6 100644 --- a/frontend/src/components/StockOverview.tsx +++ b/frontend/src/components/StockOverview.tsx @@ -265,6 +265,7 @@ function StockList({ } function formatSyncStatus(job: SyncJob): string { + if (!job || !job.id) return '状态未知' if (job.status === 'running') return '同步中…' const ts = job.finished_at || job.started_at let timeStr = '时间未知'