diff --git a/src/components/RunwayLooks.astro b/src/components/RunwayLooks.astro index faca286..84e1979 100644 --- a/src/components/RunwayLooks.astro +++ b/src/components/RunwayLooks.astro @@ -275,11 +275,12 @@ const seasonOptions: { value: string; label: string }[] = [ locale: '', hotBrands, SPIN_SVG, + // 侧栏分组折叠状态:默认全部收起(不做 localStorage 持久化,每次进页都是关着的)。 collapsedGroups: { - designers: localStorage.getItem("showsg-designers") === "1", - collection: localStorage.getItem("showsg-collection") === "1", - season: localStorage.getItem("showsg-season") === "1", - year: localStorage.getItem("showsg-year") === "1", + designers: true, + collection: true, + season: true, + year: true, }, selectedBrand: null as (string | null), selectedCt: "" as string, @@ -342,10 +343,9 @@ const seasonOptions: { value: string; label: string }[] = [ return list }, - // 点击抽屉开关 + // 点击抽屉开关:仅切换内存状态,刷新后回到默认(全部收起) toggleGroup(group: "designers" | "collection" | "season" | "year") { this.collapsedGroups[group] = !this.collapsedGroups[group] - localStorage.setItem(`showsg-${group}`, this.collapsedGroups[group] ? "1" : "") }, refreshFilter() { @@ -491,9 +491,16 @@ const seasonOptions: { value: string; label: string }[] = [ // 渲染文章url itemHref(it: { id: string | number }) { return clientHref(this.locale, ROUTES.item(it.id)) }, - // 渲染thumb图片列表(复用共享工具:固定 5 槽位 + 末位 moreLabel 兜底) + // 渲染 thumb 图片列表(复用共享工具):固定 5 个槽位 + 末位叠加「共 N 张」遮罩。 + // + // 注意参数顺序:makeCardSlots(images, count, opts) —— 第二个参数是「槽位数量」不是图片总数。 + // 曾误把 it.image_count(如 31)传成 count,导致每张卡片生成 31 个槽位(大量灰色占位块)。 + // 图片总数只用于末位遮罩文案,通过 moreLabel 回调传入。 getCardSlots(it: ArticleItem) { - return makeCardSlots(it.gallery || [], it.image_count || 0) + const total = it.image_count || 0 + return makeCardSlots(it.gallery || [], 5, { + moreLabel: () => (total > 30 ? "30+" : `${total}+`), + }) } } }) diff --git a/src/components/StreetSnaps.astro b/src/components/StreetSnaps.astro index 4dbd54e..cc8510c 100644 --- a/src/components/StreetSnaps.astro +++ b/src/components/StreetSnaps.astro @@ -196,8 +196,8 @@ const sortOptions: { value: string; label: string }[] = [ selectedYear: '' as string, selectedSort: DEFAULT_SORT as string, - // 侧栏分组折叠状态 - collapsedGroups: { year: false, sort: false } as Record, + // 侧栏分组折叠状态:默认全部收起(不做持久化,每次进页都是关着的) + collapsedGroups: { year: true, sort: true } as Record, items: [] as (StreetSnapItem & { _imgLoaded?: boolean })[], loading: false, diff --git a/src/lib/api.ts b/src/lib/api.ts index 9faa3d6..b41492c 100644 --- a/src/lib/api.ts +++ b/src/lib/api.ts @@ -90,7 +90,8 @@ export interface SsgPopularBrand { // ===================== base 解析 ===================== -export function getBase(): string { +// 仅本模块内部使用(toAbs / request 等),不对外导出。 +function getBase(): string { // if (import.meta.env.DEV) return "https://seo.23cm.cn" // 运行期/预渲染统一走 BASE_API(空则同源相对 /api) return (BASE_API || "").replace(/\/$/, "") @@ -192,7 +193,8 @@ async function request(path: string, params?: URLSearchParams): Promise { // 接口:GET /api/public/runway-looks/:id // 走秀详情(含完整图片集)。base 默认走 ssrBase()(运行期按需渲染取数),也可显式传入。 // locale 显式传入时优先(按需渲染 SSR 用它避免并发串 locale),否则走 currentLocale()。 -export async function fetchArticleById( +// 仅本模块内部使用(getSsrArticle 在其之上包一层),不对外导出。 +async function fetchArticleById( id: number | string, base: string = ssrBase(), locale?: string @@ -327,12 +329,9 @@ export async function fetchMe(): Promise { } } -// 登录/注册成功后写入本地会话(token + user),供 Layout 顶部已登录态与 fetchMe 读取。 -export function saveSession(token: string, user: AuthUser): void { - if (typeof localStorage === "undefined") return - localStorage.setItem(TOKEN_KEY, token) - localStorage.setItem(USER_KEY, JSON.stringify(user)) -} +// 注:saveSession(登录/注册成功后写 token+user 进 localStorage)已移除—— +// 站点没有登录注册入口,后端 POST /auth/register、POST /auth/login 也已下线。 +// 将来接入时恢复此函数,并补回后端注册/登录接口与前端表单。 // ===================== SSG 构建专用(/api/ssg/*,仅 Node 构建期) ===================== @@ -442,7 +441,8 @@ export async function getStreetSnaps(q: { // 接口:GET /api/public/street-snaps/:id // 街拍详情(含完整图片集)。base 默认走 ssrBase()(运行期按需渲染取数)。 -export async function fetchStreetSnapById( +// 仅本模块内部使用(getSsrStreetSnap 在其之上包一层),不对外导出。 +async function fetchStreetSnapById( id: number | string, base: string = ssrBase(), locale?: string