feat(admin): 站点信息 + 注册开关可后台设置,模板动态渲染

新增 4 项可配置站点设置(DB持久化+内存缓存,即时生效):
- site.brand          品牌名(页面标题/页脚/管理面板,默认 MetaLab)
- site.framework      框架名(页脚标识,默认 MetaZone)
- site.copyright_start 版权起始年(页脚,默认 2024)
- registration.enabled 注册开关(关闭后禁止新用户注册,默认 true)

实现方式:
- InjectSiteInfo 中间件:全局注入 Brand/Framework/CopyrightStart 到 gin.Context
- BuildPageData 读取 context,所有 SSR 页面自动获取站点信息
- AuthService.Register 最先检查 IsRegistrationEnabled()
- 管理后台新增「基本设置」+「注册设置」区块,文本输入手动保存 + Toggle 即时生效
This commit is contained in:
2026-05-27 15:12:28 +08:00
parent 7bc2dbd970
commit 0b948cf70f
16 changed files with 216 additions and 28 deletions

View File

@ -51,6 +51,8 @@ func (ac *AuthController) Register(c *gin.Context) {
common.Error(c, http.StatusConflict, "该邮箱已注册")
case common.ErrWeakPassword:
common.Error(c, http.StatusBadRequest, err.Error())
case common.ErrRegistrationDisabled:
common.Error(c, http.StatusForbidden, "注册功能已关闭")
default:
common.Error(c, http.StatusInternalServerError, "注册失败,请稍后重试")
}