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

This commit is contained in:
toom1996
2026-08-18 20:33:56 +08:00
parent c592b9a473
commit d14dd7e2db
13 changed files with 1175 additions and 187 deletions

View File

@ -17,9 +17,11 @@ export type RawArticle = {
description?: string
cover: string
brand_name: string
brand_id?: number
year: number
image_count: number
published_at: number
created_at?: number
source_url?: string
collection_type?: string
season?: string
@ -113,10 +115,11 @@ export function loadArticles(): Promise<Loaded> {
return _loaded
}
export async function fetchArticleById(id: number | string): Promise<RawArticle | null> {
if (!API_BASE) return null
export async function fetchArticleById(id: number | string, apiBase: string = API_BASE): Promise<RawArticle | null> {
const base = apiBase.replace(/\/$/, "")
if (!base) return null
try {
const res = await fetch(`${API_BASE}/api/public/articles/${id}`)
const res = await fetch(`${base}/api/public/articles/${id}`)
if (!res.ok) return null
const json: any = await res.json()
return json?.data ?? null