类别显示名可自己维护,顺手把两套对不上的中文名合成一套

你要改的那个「海滩」原来根本不在数据里——它是 Go 里硬编码的 map,所以改不动。
更糟的是这样的 map 有**两张**,而且对不上:

  MKPOICategoryFoodMarket   菜市场(编辑页)  /  食品市场(补全页、GPX)
  MKPOICategoryCafe         咖啡馆              /  咖啡厅
  MKPOICategoryFitnessCenter 健身房             /  健身中心
  外加 ATM / Atm 大小写各写一份、一条永远匹配不上的 MKPOICategoryMarina2

现在合成一张内置表(42 条,冲突处取编辑页那套),并在它上面加了一层站点覆盖:

- 新表 category_labels(value, label),站点级、不挂 dataset——值本身才是稳定键
- 端点 POST /admin/edit/category/label;传空 label = 删掉覆盖行、恢复内置默认名
- 类别台账那行改成两个带标签的输入框:
      导出值 [MKPOICategoryBeach]   ← 会跟着导出写回手机
      显示名 [               ]      ← 只影响站内显示,placeholder 写着默认值
  是 MKPOICategory 枚举但内置表里没有的,会提示「填一个中文名」,这就是你要的补全入口

**显示名绝不写进 places.poi_category**——中文跟着写进去就把导出数据污染了,
专门加了 TestCategoryLabelNeverTouchesValue 钉这条。显示名会贯穿到所有中文名的地方:
编辑页/照片页/补全页的下拉、补全页「在用」标签、访客地点页、GPX 的 desc。

连带删掉两个绑在旧表上的模板函数 catName / poiname:模板里算不出显示名(要读站点覆盖),
改成在 Go 侧算好塞进数据(FillupRow.CatLabel、PlaceData.CategoryLabel)。
This commit is contained in:
tamakyi
2026-09-20 10:54:51 +08:00
parent cbb45b6d6b
commit 82e63412c0
12 changed files with 287 additions and 83 deletions
+2 -1
View File
@@ -51,6 +51,7 @@ func (s *Server) adminPhotosPage(w http.ResponseWriter, r *http.Request) {
p.Flatpickr = true
p.HasMap = true
d := PhotoData{Page: p, GeocodeReady: s.cfg.GeocodeKey != ""}
catNames := s.categoryLabels(r.Context())
ds, err := s.datasetFor(r.Context())
if err != nil {
s.serverError(w, r, err)
@@ -81,7 +82,7 @@ func (s *Server) adminPhotosPage(w http.ResponseWriter, r *http.Request) {
s.serverError(w, r, err)
return
}
d.Categories = append(d.Categories, EditOption{Label: c, Name: poiCategoryLabel(c)})
d.Categories = append(d.Categories, EditOption{Label: c, Name: categoryLabel(c, catNames)})
}
crows.Close()
}