fix: default cover url
This commit is contained in:
@@ -5,6 +5,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@@ -13,6 +14,8 @@ import (
|
|||||||
"mengyastore-backend/internal/models"
|
"mengyastore-backend/internal/models"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const defaultCoverURL = "https://img.shumengya.top/i/2026/01/04/695a55058c37f.png"
|
||||||
|
|
||||||
type JSONStore struct {
|
type JSONStore struct {
|
||||||
path string
|
path string
|
||||||
mu sync.Mutex
|
mu sync.Mutex
|
||||||
@@ -185,6 +188,10 @@ func (s *JSONStore) writeAll(items []models.Product) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func normalizeProduct(item models.Product) models.Product {
|
func normalizeProduct(item models.Product) models.Product {
|
||||||
|
item.CoverURL = strings.TrimSpace(item.CoverURL)
|
||||||
|
if item.CoverURL == "" {
|
||||||
|
item.CoverURL = defaultCoverURL
|
||||||
|
}
|
||||||
if item.ScreenshotURLs == nil {
|
if item.ScreenshotURLs == nil {
|
||||||
item.ScreenshotURLs = []string{}
|
item.ScreenshotURLs = []string{}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user