chore: 移除 site.brand 可配置功能,站点名称恢复硬编码 MetaLab
考虑实际需求后,站点名称无需常改,移除前后端全部相关逻辑: - config / middleware / helper 移除 site_brand 注入 - 页脚版权恢复硬编码 MetaLab
This commit is contained in:
@ -57,9 +57,6 @@ func BuildAdminPageData(c *gin.Context, extra gin.H) gin.H {
|
|||||||
|
|
||||||
// injectSiteInfo 从 context 注入站点展示信息
|
// injectSiteInfo 从 context 注入站点展示信息
|
||||||
func injectSiteInfo(c *gin.Context, data gin.H) {
|
func injectSiteInfo(c *gin.Context, data gin.H) {
|
||||||
if brand, exists := c.Get("site_brand"); exists {
|
|
||||||
data["Brand"] = brand
|
|
||||||
}
|
|
||||||
if framework, exists := c.Get("site_framework"); exists {
|
if framework, exists := c.Get("site_framework"); exists {
|
||||||
data["Framework"] = framework
|
data["Framework"] = framework
|
||||||
}
|
}
|
||||||
|
|||||||
@ -112,16 +112,14 @@ func (s *SiteSettings) IsAuditTypeEnabled(auditType string, defaultVal bool) boo
|
|||||||
|
|
||||||
// SiteInfoDefaults 站点展示信息的默认值
|
// SiteInfoDefaults 站点展示信息的默认值
|
||||||
type SiteInfoDefaults struct {
|
type SiteInfoDefaults struct {
|
||||||
Brand string // 品牌名,默认 "MetaLab"
|
Framework string // 附加标识,默认 "Framework: MetaZone"
|
||||||
Framework string // 框架名,默认 "MetaZone"
|
|
||||||
CopyrightStart string // 版权起始年份,默认 "2024"
|
CopyrightStart string // 版权起始年份,默认 "2024"
|
||||||
}
|
}
|
||||||
|
|
||||||
// SiteInfo 获取站点展示信息(优先 DB 设置,fallback 默认值)
|
// SiteInfo 获取站点展示信息(优先 DB 设置,fallback 默认值)
|
||||||
func (s *SiteSettings) SiteInfo() SiteInfoDefaults {
|
func (s *SiteSettings) SiteInfo() SiteInfoDefaults {
|
||||||
return SiteInfoDefaults{
|
return SiteInfoDefaults{
|
||||||
Brand: s.Get("site.brand", "MetaLab"),
|
Framework: s.Get("site.framework", "Framework: MetaZone"),
|
||||||
Framework: s.Get("site.framework", "MetaZone"),
|
|
||||||
CopyrightStart: s.Get("site.copyright_start", "2024"),
|
CopyrightStart: s.Get("site.copyright_start", "2024"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -7,11 +7,10 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// InjectSiteInfo 注入站点展示信息到请求上下文(供 BuildPageData 使用)
|
// InjectSiteInfo 注入站点展示信息到请求上下文(供 BuildPageData 使用)
|
||||||
// 应用于引擎级全局中间件,确保所有 SSR 页面都能读取 Brand/Framework/CopyrightStart
|
// 应用于引擎级全局中间件,确保所有 SSR 页面都能读取 Framework/CopyrightStart
|
||||||
func InjectSiteInfo(siteSettings *config.SiteSettings) gin.HandlerFunc {
|
func InjectSiteInfo(siteSettings *config.SiteSettings) gin.HandlerFunc {
|
||||||
return func(c *gin.Context) {
|
return func(c *gin.Context) {
|
||||||
info := siteSettings.SiteInfo()
|
info := siteSettings.SiteInfo()
|
||||||
c.Set("site_brand", info.Brand)
|
|
||||||
c.Set("site_framework", info.Framework)
|
c.Set("site_framework", info.Framework)
|
||||||
c.Set("site_copyright_start", info.CopyrightStart)
|
c.Set("site_copyright_start", info.CopyrightStart)
|
||||||
c.Next()
|
c.Next()
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
<footer>
|
<footer>
|
||||||
<div class="container footer-content">
|
<div class="container footer-content">
|
||||||
<p class="copyright">© {{.CopyrightStart}}-2026 {{.Brand}}{{if .Framework}} | {{.Framework}}{{end}}{{if .CanAccessAdmin}} | <a href="/admin">管理面板</a>{{end}}</p>
|
<p class="copyright">© {{.CopyrightStart}}-2026 MetaLab{{if .Framework}} | {{.Framework}}{{end}}{{if .CanAccessAdmin}} | <a href="/admin">管理面板</a>{{end}}</p>
|
||||||
</div>
|
</div>
|
||||||
</footer>
|
</footer>
|
||||||
|
|||||||
Reference in New Issue
Block a user