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:
@ -22,14 +22,14 @@ type dependencies struct {
|
||||
tokenCtrl *controller.AuthController
|
||||
}
|
||||
|
||||
func buildDepsCore(db *gorm.DB, cfg *config.Config) (
|
||||
func buildDepsCore(db *gorm.DB, cfg *config.Config, siteSettings *config.SiteSettings) (
|
||||
*repository.UserRepo, *service.TokenService, *service.AuthService,
|
||||
*middleware.RateLimiter, *controller.AuthController,
|
||||
*service.AvatarService, *middleware.AuthMiddleware, *adminCtrl.AdminController,
|
||||
) {
|
||||
userRepo := repository.NewUserRepo(db)
|
||||
tokenSvc := service.NewTokenService(cfg, userRepo)
|
||||
authService := service.NewAuthService(userRepo, tokenSvc, cfg)
|
||||
authService := service.NewAuthService(userRepo, tokenSvc, cfg, siteSettings)
|
||||
rateLimiter := middleware.NewRateLimiter()
|
||||
authCtrl := controller.NewAuthController(authService, tokenSvc, rateLimiter, cfg)
|
||||
avatarSvc := service.NewAvatarService(userRepo)
|
||||
|
||||
Reference in New Issue
Block a user