修 test01:窄屏装饰全藏导致素材消失、主题名显示成 i18n key

- 生成器:勾「窄屏隐藏全部装饰层」时给橙色警告(几层会消失)、图层行标「窄屏隐藏」、加层与导出结果再提醒;「窄屏」下拉在被全藏覆盖时标注不生效
- 新增 ?narrow=hide 复现该状态(这是「素材在手机上看不到」的头号来源:@media 把 10 槽全写 none,桌面完全正常)
- 主题名:新增 theme.DisplayName + 模板函数 themeName,i18n 未登记 theme.name.<slug> 时回退 slug;原来模板直接调用 i18n.T,缺词条就显示 "theme.name.test01"
- test01.css 删掉 @media 全 none 段:装饰是 fit 单位,浏览器会自己按视口缩,不需要这段
- StaticVersion → 20261020g(主题 css 内容变了,必须换缓存键,否则浏览器还会用旧文件)
This commit is contained in:
tamakyi
2026-10-20 18:23:21 +08:00
parent 3d0239d8f1
commit 6c014b3ad2
8 changed files with 110 additions and 105 deletions
+15
View File
@@ -14,6 +14,7 @@ import (
"github.com/sirupsen/logrus"
"github.com/tamakyi/TamaBox/internal/conf"
"github.com/tamakyi/TamaBox/internal/i18n"
"github.com/tamakyi/TamaBox/static"
)
@@ -46,6 +47,20 @@ var (
siteDef string // 站点默认主题;空串表示「基础外观,不加载主题 css」
)
// DisplayName 返回主题在设置页里的显示名。
//
// 优先取 i18n 的 theme.name.<slug>;**没登记就原样返回 slug**。
// 这条回退是必需的:自建主题(生成器导出的)只放一个 css 就到手,
// 不该为了显示名去改四份词典 —— 否则设置页会把 key 直接印出来(theme.name.test01),
// 而 i18n.T 缺词条时返回 key 本身,调用方无从判断「是缺失还是文案就叫这个」。
func DisplayName(lang, slug string) string {
key := "theme.name." + slug
if name := i18n.T(lang, key); name != key {
return name
}
return slug
}
func load() {
once.Do(func() {
themes, siteDef, bySlug = build(conf.Theme.Default, conf.Theme.Available)