@ -275,11 +275,12 @@ const seasonOptions: { value: string; label: string }[] = [
|
|||||||
locale: '',
|
locale: '',
|
||||||
hotBrands,
|
hotBrands,
|
||||||
SPIN_SVG,
|
SPIN_SVG,
|
||||||
|
// 侧栏分组折叠状态:默认全部收起(不做 localStorage 持久化,每次进页都是关着的)。
|
||||||
collapsedGroups: {
|
collapsedGroups: {
|
||||||
designers: localStorage.getItem("showsg-designers") === "1",
|
designers: true,
|
||||||
collection: localStorage.getItem("showsg-collection") === "1",
|
collection: true,
|
||||||
season: localStorage.getItem("showsg-season") === "1",
|
season: true,
|
||||||
year: localStorage.getItem("showsg-year") === "1",
|
year: true,
|
||||||
},
|
},
|
||||||
selectedBrand: null as (string | null),
|
selectedBrand: null as (string | null),
|
||||||
selectedCt: "" as string,
|
selectedCt: "" as string,
|
||||||
@ -342,10 +343,9 @@ const seasonOptions: { value: string; label: string }[] = [
|
|||||||
return list
|
return list
|
||||||
},
|
},
|
||||||
|
|
||||||
// 点击抽屉开关
|
// 点击抽屉开关:仅切换内存状态,刷新后回到默认(全部收起)
|
||||||
toggleGroup(group: "designers" | "collection" | "season" | "year") {
|
toggleGroup(group: "designers" | "collection" | "season" | "year") {
|
||||||
this.collapsedGroups[group] = !this.collapsedGroups[group]
|
this.collapsedGroups[group] = !this.collapsedGroups[group]
|
||||||
localStorage.setItem(`showsg-${group}`, this.collapsedGroups[group] ? "1" : "")
|
|
||||||
},
|
},
|
||||||
|
|
||||||
refreshFilter() {
|
refreshFilter() {
|
||||||
@ -491,9 +491,16 @@ const seasonOptions: { value: string; label: string }[] = [
|
|||||||
// 渲染文章url
|
// 渲染文章url
|
||||||
itemHref(it: { id: string | number }) { return clientHref(this.locale, ROUTES.item(it.id)) },
|
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) {
|
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}+`),
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
@ -196,8 +196,8 @@ const sortOptions: { value: string; label: string }[] = [
|
|||||||
selectedYear: '' as string,
|
selectedYear: '' as string,
|
||||||
selectedSort: DEFAULT_SORT as string,
|
selectedSort: DEFAULT_SORT as string,
|
||||||
|
|
||||||
// 侧栏分组折叠状态
|
// 侧栏分组折叠状态:默认全部收起(不做持久化,每次进页都是关着的)
|
||||||
collapsedGroups: { year: false, sort: false } as Record<string, boolean>,
|
collapsedGroups: { year: true, sort: true } as Record<string, boolean>,
|
||||||
|
|
||||||
items: [] as (StreetSnapItem & { _imgLoaded?: boolean })[],
|
items: [] as (StreetSnapItem & { _imgLoaded?: boolean })[],
|
||||||
loading: false,
|
loading: false,
|
||||||
|
|||||||
@ -90,7 +90,8 @@ export interface SsgPopularBrand {
|
|||||||
|
|
||||||
// ===================== base 解析 =====================
|
// ===================== base 解析 =====================
|
||||||
|
|
||||||
export function getBase(): string {
|
// 仅本模块内部使用(toAbs / request 等),不对外导出。
|
||||||
|
function getBase(): string {
|
||||||
// if (import.meta.env.DEV) return "https://seo.23cm.cn"
|
// if (import.meta.env.DEV) return "https://seo.23cm.cn"
|
||||||
// 运行期/预渲染统一走 BASE_API(空则同源相对 /api)
|
// 运行期/预渲染统一走 BASE_API(空则同源相对 /api)
|
||||||
return (BASE_API || "").replace(/\/$/, "")
|
return (BASE_API || "").replace(/\/$/, "")
|
||||||
@ -192,7 +193,8 @@ async function request<T>(path: string, params?: URLSearchParams): Promise<T> {
|
|||||||
// 接口:GET /api/public/runway-looks/:id
|
// 接口:GET /api/public/runway-looks/:id
|
||||||
// 走秀详情(含完整图片集)。base 默认走 ssrBase()(运行期按需渲染取数),也可显式传入。
|
// 走秀详情(含完整图片集)。base 默认走 ssrBase()(运行期按需渲染取数),也可显式传入。
|
||||||
// locale 显式传入时优先(按需渲染 SSR 用它避免并发串 locale),否则走 currentLocale()。
|
// locale 显式传入时优先(按需渲染 SSR 用它避免并发串 locale),否则走 currentLocale()。
|
||||||
export async function fetchArticleById(
|
// 仅本模块内部使用(getSsrArticle 在其之上包一层),不对外导出。
|
||||||
|
async function fetchArticleById(
|
||||||
id: number | string,
|
id: number | string,
|
||||||
base: string = ssrBase(),
|
base: string = ssrBase(),
|
||||||
locale?: string
|
locale?: string
|
||||||
@ -327,12 +329,9 @@ export async function fetchMe(): Promise<AuthUser | null> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 登录/注册成功后写入本地会话(token + user),供 Layout 顶部已登录态与 fetchMe 读取。
|
// 注:saveSession(登录/注册成功后写 token+user 进 localStorage)已移除——
|
||||||
export function saveSession(token: string, user: AuthUser): void {
|
// 站点没有登录注册入口,后端 POST /auth/register、POST /auth/login 也已下线。
|
||||||
if (typeof localStorage === "undefined") return
|
// 将来接入时恢复此函数,并补回后端注册/登录接口与前端表单。
|
||||||
localStorage.setItem(TOKEN_KEY, token)
|
|
||||||
localStorage.setItem(USER_KEY, JSON.stringify(user))
|
|
||||||
}
|
|
||||||
|
|
||||||
// ===================== SSG 构建专用(/api/ssg/*,仅 Node 构建期) =====================
|
// ===================== SSG 构建专用(/api/ssg/*,仅 Node 构建期) =====================
|
||||||
|
|
||||||
@ -442,7 +441,8 @@ export async function getStreetSnaps(q: {
|
|||||||
|
|
||||||
// 接口:GET /api/public/street-snaps/:id
|
// 接口:GET /api/public/street-snaps/:id
|
||||||
// 街拍详情(含完整图片集)。base 默认走 ssrBase()(运行期按需渲染取数)。
|
// 街拍详情(含完整图片集)。base 默认走 ssrBase()(运行期按需渲染取数)。
|
||||||
export async function fetchStreetSnapById(
|
// 仅本模块内部使用(getSsrStreetSnap 在其之上包一层),不对外导出。
|
||||||
|
async function fetchStreetSnapById(
|
||||||
id: number | string,
|
id: number | string,
|
||||||
base: string = ssrBase(),
|
base: string = ssrBase(),
|
||||||
locale?: string
|
locale?: string
|
||||||
|
|||||||
Reference in New Issue
Block a user