update
Some checks failed
deploy / deploy (push) Has been cancelled

This commit is contained in:
toom1996
2026-08-15 01:07:33 +08:00
parent 8d65eb8850
commit 58f9f95f8e
8 changed files with 1383 additions and 600 deletions

View File

@ -66,15 +66,21 @@ async function request<T>(path: string, params?: URLSearchParams): Promise<T> {
}
// 侧边栏品牌清单(含 article_count 计数)
// 支持 keyword(模糊搜索 name/show_name)/ letter(A-Z 或 OTHER=中文)/ featured(精选)参数,
// 用于品牌筛选弹窗的「搜索 + A-Z 跳转 + 热门推荐」三种按需加载,避免一次拉全量。
export async function getBrands(opts?: {
size?: number
only_with_articles?: number
featured?: number
keyword?: string
letter?: string
}): Promise<BrandEntry[]> {
const qs = new URLSearchParams()
if (opts?.size) qs.set("size", String(opts.size))
if (opts?.only_with_articles) qs.set("only_with_articles", String(opts.only_with_articles))
if (opts?.featured) qs.set("featured", String(opts.featured))
if (opts?.only_with_articles != null) qs.set("only_with_articles", String(opts.only_with_articles))
if (opts?.featured != null) qs.set("featured", String(opts.featured))
if (opts?.keyword) qs.set("keyword", opts.keyword)
if (opts?.letter) qs.set("letter", opts.letter)
const j = await request<{ data?: any[] }>("/public/brands", qs)
return (j.data ?? []).map((b: any) => ({
id: Number(b.id),