@ -68,7 +68,7 @@ export type RawArticle = {
|
||||
brand_name: string
|
||||
brand_id?: string | number // hashid 编码串
|
||||
image_count?: number // 列表卡片 "N+" 角标用(仅列表接口返回)
|
||||
images?: { id?: number; image: string; name?: string }[]
|
||||
images?: { id?: string; image: string; name?: string }[] // id 为图片自身的编码串(i/j 前缀),单图收藏用
|
||||
}
|
||||
|
||||
export interface AuthUser {
|
||||
@ -466,25 +466,9 @@ export async function logout(): Promise<void> {
|
||||
clearSession()
|
||||
}
|
||||
|
||||
// 踢下线:吊销当前用户所有 refresh_token(全设备退出)。
|
||||
export async function logoutAll(): Promise<void> {
|
||||
const refresh = getRefreshToken()
|
||||
if (refresh) {
|
||||
try {
|
||||
await fetch(`${BASE_API_URL}/api/v1/auth/logout-all`, {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ refresh_token: refresh }),
|
||||
})
|
||||
} catch {
|
||||
/* 忽略网络错误,仍清本地态 */
|
||||
}
|
||||
}
|
||||
clearSession()
|
||||
}
|
||||
|
||||
// ===================== 浏览历史:单篇详情回查(账户页 My History 渲染用) =====================
|
||||
// 历史只存文章对外编码串(r= 走秀 / s= 街拍),展示时逐篇回查公开详情接口取 title/cover/brand。
|
||||
// 历史只存文章对外编码串,展示时逐篇回查公开详情接口取 title/cover/brand。
|
||||
// 编码串首字符即类型:s=… 实为 s 开头(如 s000zAwwQ)代表街拍,其余(r 开头等)为走秀。
|
||||
// 走 request():自动带 locale 与前端签名,登录态附带 Bearer。
|
||||
|
||||
export interface HistoryMeta {
|
||||
@ -494,10 +478,11 @@ export interface HistoryMeta {
|
||||
type: "street" | "runway"
|
||||
}
|
||||
|
||||
// 单篇回查:编码串自带类型(s= 前缀街拍,其余走秀)。失败返回 null,由调用方容忍。
|
||||
// 单篇回查:按编码串首字符判断类型(s 开头 = 街拍,其余 = 走秀)。失败返回 null,由调用方容忍。
|
||||
export async function getHistoryMeta(id: string): Promise<HistoryMeta | null> {
|
||||
const sid = String(id)
|
||||
const type = sid.startsWith("s=") ? ("street" as const) : ("runway" as const)
|
||||
// 编码串类型前缀是单个字符(如 s000zAwwQ),与 /item/[id] 路由判断一致(r= 走秀 / s= 街拍)
|
||||
const type = sid.charAt(0) === "s" ? ("street" as const) : ("runway" as const)
|
||||
const path =
|
||||
type === "street"
|
||||
? `/public/street-snaps/${encodeURIComponent(sid)}`
|
||||
@ -583,7 +568,7 @@ export interface StreetSnapItem {
|
||||
title: string // 含字面 \t 分隔:地点 \t 场次
|
||||
cover: string
|
||||
image_count: number
|
||||
images: { image: string; name: string }[] // 列表附带的每篇前 N 张缩略图
|
||||
images: { id?: string; image: string; name?: string }[] // 列表附带的每篇前 N 张缩略图(id 为图片自身的编码串)
|
||||
}
|
||||
|
||||
// 列表响应(与走秀 ArticlePage 同构)
|
||||
@ -597,7 +582,7 @@ export interface RawStreetSnap {
|
||||
id: string
|
||||
title: string
|
||||
cover: string
|
||||
images?: { id?: number; image: string; name?: string }[]
|
||||
images?: { id?: string; image: string; name?: string }[] // id 为图片自身的编码串(i/j 前缀),单图收藏用
|
||||
}
|
||||
|
||||
// 接口:GET /api/public/street-snaps
|
||||
@ -620,7 +605,10 @@ export async function getStreetSnaps(q: {
|
||||
title: it.title ?? "",
|
||||
cover: it.cover ?? "",
|
||||
image_count: Number(it.image_count ?? 0),
|
||||
images: Array.isArray(it.images) ? it.images.map((im: any) => ({ image: im.image || im, name: im.name || "" })) : [],
|
||||
// 保留每张图的 id(图片编码串),单图收藏需要用它定位到具体某一张
|
||||
images: Array.isArray(it.images)
|
||||
? it.images.map((im: any) => ({ id: im.id || "", image: im.image || im, name: im.name || "" }))
|
||||
: [],
|
||||
}))
|
||||
return { data: mapped, last_page: Number(j.last_page ?? 1) }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user