diff --git a/mengyastore-backend/internal/storage/jsonstore.go b/mengyastore-backend/internal/storage/jsonstore.go index aef0765..ee2dca8 100644 --- a/mengyastore-backend/internal/storage/jsonstore.go +++ b/mengyastore-backend/internal/storage/jsonstore.go @@ -5,6 +5,7 @@ import ( "fmt" "os" "path/filepath" + "strings" "sync" "time" @@ -13,6 +14,8 @@ import ( "mengyastore-backend/internal/models" ) +const defaultCoverURL = "https://img.shumengya.top/i/2026/01/04/695a55058c37f.png" + type JSONStore struct { path string mu sync.Mutex @@ -185,6 +188,10 @@ func (s *JSONStore) writeAll(items []models.Product) error { } func normalizeProduct(item models.Product) models.Product { + item.CoverURL = strings.TrimSpace(item.CoverURL) + if item.CoverURL == "" { + item.CoverURL = defaultCoverURL + } if item.ScreenshotURLs == nil { item.ScreenshotURLs = []string{} }