This commit is contained in:
toom1996
2026-08-26 19:40:16 +08:00
parent 30c9f21da4
commit a6724265ad
14 changed files with 400 additions and 101 deletions

View File

@ -51,7 +51,9 @@ func (s *articleService) List(ctx context.Context, q dto.ArticleQuery) ([]dto.Pu
Title: pickLocale(r.TitleEn, r.TitleCn, q.Locale),
Summary: textutil.Summarize(pickLocale(r.DescriptionEn, r.DescriptionCn, q.Locale), summaryLength),
Cover: r.Cover,
BrandName: pickLocale(r.BrandNameEn, r.BrandNameCn, q.Locale),
// 品牌名强制优先英文("en"),仅在英文缺失时回落中文,避免留空;
// 与 title/description 不同,品牌名不随 locale 切换,保持英文观感。
BrandName: pickLocale(r.BrandNameEn, r.BrandNameCn, "en"),
Year: r.Year,
ImageCount: r.ImageCount,
CollectionType: r.CollectionType,
@ -111,7 +113,8 @@ func (s *articleService) Detail(ctx context.Context, id string, locale string) (
Summary: textutil.Summarize(pickLocale(row.DescriptionEn, row.DescriptionCn, locale), summaryLength),
Description: pickLocale(row.DescriptionEn, row.DescriptionCn, locale),
Cover: row.Cover,
BrandName: pickLocale(row.BrandNameEn, row.BrandNameCn, locale),
// 品牌名强制优先英文("en"),不随 locale 切换,保持英文观感。
BrandName: pickLocale(row.BrandNameEn, row.BrandNameCn, "en"),
Year: row.Year,
ImageCount: row.ImageCount,
SourceURL: row.SourceURL,