feat: 品牌CMS配置化 + cookie_secure配置
- config.yaml 新增 server.cookie_secure 配置项
- site_settings 新增 site_name/site_tagline/contact_email 站点信息
- SiteInfo 结构体扩展,支持运行时从 DB 读取站点品牌信息
- cookie.go 使用 cfg.Server.CookieSecure 替代 Mode!=debug 判断
- SetSessionCookie/ClearSessionCookie 支持 siteSettings 运行时覆盖
- 模板替换硬编码 MetaLab → {{.SiteName}}(nav/header/footer/home/login/register/guidelines/admin,12+处)
- 管理后台站点设置页新增站点名称/标语/联系邮箱输入项
- 页脚版权年份改为动态 CurrentYear
- 注册成功消息 CMS 化(后端+前端)
This commit is contained in:
@ -112,18 +112,29 @@ func (s *SiteSettings) IsAuditTypeEnabled(auditType string, defaultVal bool) boo
|
||||
|
||||
// SiteInfoDefaults 站点展示信息的默认值
|
||||
type SiteInfoDefaults struct {
|
||||
Framework string // 附加标识,默认 "Framework: MetaZone"
|
||||
SiteName string // 站点名称,默认 "MetaLab"
|
||||
SiteTagline string // 站点标语,默认 "下一代开发者社区"
|
||||
ContactEmail string // 联系/申诉邮箱,默认 "metazone@foxmail.com"
|
||||
Framework string // 附加标识,默认 "Framework: MetaGenesis"
|
||||
CopyrightStart string // 版权起始年份,默认 "2024"
|
||||
}
|
||||
|
||||
// SiteInfo 获取站点展示信息(优先 DB 设置,fallback 默认值)
|
||||
func (s *SiteSettings) SiteInfo() SiteInfoDefaults {
|
||||
return SiteInfoDefaults{
|
||||
Framework: s.Get("site.framework", "Framework: MetaZone"),
|
||||
SiteName: s.Get("site.name", "MetaLab"),
|
||||
SiteTagline: s.Get("site.tagline", "下一代开发者社区"),
|
||||
ContactEmail: s.Get("site.contact_email", "metazone@foxmail.com"),
|
||||
Framework: s.Get("site.framework", "Framework: MetaGenesis"),
|
||||
CopyrightStart: s.Get("site.copyright_start", "2024"),
|
||||
}
|
||||
}
|
||||
|
||||
// CookieSecure 返回 cookie_secure 配置值(优先站点设置,fallback config.yaml)
|
||||
func (s *SiteSettings) CookieSecure() bool {
|
||||
return s.GetBool("site.cookie_secure", App.Server.CookieSecure)
|
||||
}
|
||||
|
||||
// IsRegistrationEnabled 是否允许新用户注册
|
||||
func (s *SiteSettings) IsRegistrationEnabled() bool {
|
||||
return s.GetBool("registration.enabled", true)
|
||||
|
||||
Reference in New Issue
Block a user