opt: optimize the layout for regiseter page. add function to disable registration

This commit is contained in:
RockYang
2023-08-02 17:44:13 +08:00
parent b09d23f97f
commit 4e65a5b1a1
6 changed files with 214 additions and 147 deletions

View File

@@ -85,10 +85,9 @@ type ChatConfig struct {
}
type SystemConfig struct {
Title string `json:"title"`
AdminTitle string `json:"admin_title"`
Models []string `json:"models"`
UserInitCalls int `json:"user_init_calls"` // 新用户注册默认总送多少次调用
Title string `json:"title"`
AdminTitle string `json:"admin_title"`
Models []string `json:"models"`
UserInitCalls int `json:"user_init_calls"` // 新用户注册默认总送多少次调用
EnabledRegister bool `json:"enabled_register"`
}
const UserInitCalls = 20

View File

@@ -52,12 +52,17 @@ func (h *ConfigHandler) Update(c *gin.Context) {
// update config cache for AppServer
var cfg model.Config
h.db.Where("marker", data.Key).First(&cfg)
err := utils.JsonDecode(cfg.Config, &h.App.ChatConfig)
var err error
if data.Key == "system" {
err = utils.JsonDecode(cfg.Config, &h.App.SysConfig)
} else if data.Key == "chat" {
err = utils.JsonDecode(cfg.Config, &h.App.ChatConfig)
}
if err != nil {
resp.ERROR(c, "Failed to update config cache: "+err.Error())
return
}
logger.Debugf("Update AppServer's config successfully: %v", config.Config)
logger.Infof("Update AppServer's config successfully: %v", config.Config)
}
resp.SUCCESS(c, config)

View File

@@ -59,7 +59,12 @@ func (h *SmsHandler) SendCode(c *gin.Context) {
resp.SUCCESS(c)
}
type statusVo struct {
EnabledMsgService bool `json:"enabled_msg_service"`
EnabledRegister bool `json:"enabled_register"`
}
// Status check if the message service is enabled
func (h *SmsHandler) Status(c *gin.Context) {
resp.SUCCESS(c, h.App.Config.EnabledMsgService)
resp.SUCCESS(c, statusVo{EnabledMsgService: h.App.Config.EnabledMsgService, EnabledRegister: h.App.SysConfig.EnabledRegister})
}