This commit is contained in:
toom1996
2026-09-13 00:49:42 +08:00
parent 19fb597bb4
commit c85c561a99
19 changed files with 552 additions and 245 deletions

View File

@ -204,9 +204,7 @@ const browseLabel = t("browse the archive")
favPage: 1,
favPerPage: 24,
favLastPage: 1,
favTotal: 0,
history: [] as any[],
historyCount: 0,
histPage: 1,
histPerPage: 24,
histLastPage: 1,
@ -231,14 +229,12 @@ const browseLabel = t("browse the archive")
try {
const r = await fetchFavoritesPage(p, this.favPerPage, k === "image" ? "image" : "gallery")
this.favorites = r.items
this.favTotal = r.total
this.favLastPage = r.lastPage
this.favPage = p
this.favoritesCount = r.total
} catch {
const local = getFavorites().filter((f) => (f.kind || "gallery") === (k === "image" ? "image" : "gallery"))
this.favorites = local
this.favTotal = local.length
this.favLastPage = 1
this.favPage = 1
this.favoritesCount = local.length
@ -277,9 +273,10 @@ const browseLabel = t("browse the archive")
},
itemHref(f: any): string {
// 单图收藏:跳所属图集 + ?img=<图片uid>,详情页据此滚动定位到那张图;
// 图集收藏与历史仍用自身 uid。
// 图集收藏与历史仍用自身 uid,但历史优先用回查到的 canonId(规范 id)——
// 旧的无前缀历史 id 会把用户带回非规范地址,详情页据此又写出一条重复历史。
const isImg = f.kind === "image"
const uid = isImg && f.parentUid ? f.parentUid : f.id
const uid = isImg && f.parentUid ? f.parentUid : (f.canonId || f.id)
const base = clientHref(this.locale, ROUTES.item(uid))
return isImg && f.id ? `${base}?img=${encodeURIComponent(f.id)}` : base
},

View File

@ -37,9 +37,12 @@ preview = data.preview ?? false
imageTotal = data.imageTotal ?? 0
// 供客户端「收藏 / 历史」使用的精简元信息(服务端已拿到,直接透传,避免前端再发请求)。
// id 优先取**接口回传的规范 id**(带类型前缀):用户若通过旧的无前缀链接进来(如 /item/0008CZYI),
// 也保证收藏 / 历史写入的是规范形式,不会与既有记录形成「同一篇文章两行」。
const canonId = String((isSnap ? snap?.id : article?.id) ?? id ?? "")
const meta = isSnap
? { id: id ?? "", type: "street", title: snap?.title ?? "", cover: snap?.cover ?? "", brand: "" }
: { id: id ?? "", type: "runway", title: article?.title ?? "", cover: article?.cover ?? "", brand: article?.brand_name ?? "" }
? { id: canonId, type: "street", title: snap?.title ?? "", cover: snap?.cover ?? "", brand: "" }
: { id: canonId, type: "runway", title: article?.title ?? "", cover: article?.cover ?? "", brand: article?.brand_name ?? "" }
const saveLabel = t("save")
const savedLabel = t("saved")
---

View File

@ -205,9 +205,7 @@ const browseLabel = t("browse the archive")
favPage: 1,
favPerPage: 24,
favLastPage: 1,
favTotal: 0,
history: [] as any[],
historyCount: 0,
histPage: 1,
histPerPage: 24,
histLastPage: 1,
@ -232,14 +230,12 @@ const browseLabel = t("browse the archive")
try {
const r = await fetchFavoritesPage(p, this.favPerPage, k === "image" ? "image" : "gallery")
this.favorites = r.items
this.favTotal = r.total
this.favLastPage = r.lastPage
this.favPage = p
this.favoritesCount = r.total
} catch {
const local = getFavorites().filter((f) => (f.kind || "gallery") === (k === "image" ? "image" : "gallery"))
this.favorites = local
this.favTotal = local.length
this.favLastPage = 1
this.favPage = 1
this.favoritesCount = local.length
@ -278,9 +274,10 @@ const browseLabel = t("browse the archive")
},
itemHref(f: any): string {
// 单图收藏:跳所属图集 + ?img=<图片uid>,详情页据此滚动定位到那张图;
// 图集收藏与历史仍用自身 uid。
// 图集收藏与历史仍用自身 uid,但历史优先用回查到的 canonId(规范 id)——
// 旧的无前缀历史 id 会把用户带回非规范地址,详情页据此又写出一条重复历史。
const isImg = f.kind === "image"
const uid = isImg && f.parentUid ? f.parentUid : f.id
const uid = isImg && f.parentUid ? f.parentUid : (f.canonId || f.id)
const base = clientHref(this.locale, ROUTES.item(uid))
return isImg && f.id ? `${base}?img=${encodeURIComponent(f.id)}` : base
},

View File

@ -37,9 +37,12 @@ preview = data.preview ?? false
imageTotal = data.imageTotal ?? 0
// 供客户端「收藏 / 历史」使用的精简元信息(服务端已拿到,直接透传,避免前端再发请求)。
// id 优先取**接口回传的规范 id**(带类型前缀):用户若通过旧的无前缀链接进来(如 /item/0008CZYI),
// 也保证收藏 / 历史写入的是规范形式,不会与既有记录形成「同一篇文章两行」。
const canonId = String((isSnap ? snap?.id : article?.id) ?? id ?? "")
const meta = isSnap
? { id: id ?? "", type: "street", title: snap?.title ?? "", cover: snap?.cover ?? "", brand: "" }
: { id: id ?? "", type: "runway", title: article?.title ?? "", cover: article?.cover ?? "", brand: article?.brand_name ?? "" }
? { id: canonId, type: "street", title: snap?.title ?? "", cover: snap?.cover ?? "", brand: "" }
: { id: canonId, type: "runway", title: article?.title ?? "", cover: article?.cover ?? "", brand: article?.brand_name ?? "" }
const saveLabel = t("save")
const savedLabel = t("saved")
---