修复访客在地点详情页看不到「图片」按钮

全屏画廊的地址列表原先只从 #imgs-grid 反推,而那个缩略图墙整块包在
{{if .IsAdmin}} 里——访客页根本没有这个元素,于是 syncGallery() 数到 0 张,
把服务端已经渲染好的「图片 N」按钮 remove 掉(表现成刷新后按钮闪一下就没了)。
站长自己打开一切正常,所以只有按访客身份渲染才看得到。

首版 b327bc1 就有,不是新引入的。

- 新增 PlaceData.ImageURLs:随页面把地址列表发给浏览器,访客页自带数据源。
- cellURLs() 的判据改成「缩略图墙在不在」,而不是「墙里有几张」:
  站长把图删光时墙还在、只是空了,按张数回退会把删掉的图又数回来。
- 新增回归 TestVisitorPlacePageCarriesImageURLs:按访客身份渲染详情页,
  要求页面里有「图片」按钮、且把图片地址发给了浏览器(去掉数据源即失败)。

实测(390 访客,/places/2254 三张图):按钮回归、点开 1/3 → 2/3 → 回绕 3/3 →
关闭正常,第 2 张 1200×900 实际加载;320/390/430 横向溢出均为 0。
This commit is contained in:
tamakyi
2026-09-18 19:42:52 +08:00
parent 002755129d
commit 96e76318ab
4 changed files with 66 additions and 4 deletions
+5
View File
@@ -544,6 +544,11 @@ func (s *Server) placePage(w http.ResponseWriter, r *http.Request) {
// 图片:访客也要看得到,所以不分管理员
if imgs, err := s.placeImagesOf(r.Context(), p.Dataset.ID, place.SrcPK); err == nil {
d.Images = imgs
// 地址列表单独给一份:访客页没有缩略图墙可读,画廊靠它初始化
d.ImageURLs = make([]string, 0, len(imgs))
for _, im := range imgs {
d.ImageURLs = append(d.ImageURLs, im.URL)
}
}
if p.IsAdmin() {
if backend, err := s.imageBackend(r.Context()); err == nil {