From e04856f7947f789b32dde1f5664dc82b39148901 Mon Sep 17 00:00:00 2001 From: RockYang Date: Wed, 2 Aug 2023 17:44:13 +0800 Subject: [PATCH] opt: optimize the layout for regiseter page. add function to disable registration --- CHANGELOG.md | 11 + api/core/types/config.go | 11 +- api/handler/admin/config_handler.go | 9 +- api/handler/sms_handler.go | 7 +- web/src/views/Register.vue | 320 ++++++++++++++++------------ web/src/views/admin/SysConfig.vue | 3 + 6 files changed, 214 insertions(+), 147 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c142935b..9d66d366 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,16 @@ # 更新日志 +## v3.0.6 +1. 管理后台:新增用户名和手机号码搜索功能 +2. 管理后台:新增重置用户密码功能 +3. 管理后台:支持关闭注册功能,新增添加用户功能,适用于内部使用场景 +4. 管理后台:新增仪表盘页面,统计当天的新增用户,新增会话数据,以及 Token 消耗 +5. Bug修复:修复注册页面验证码不显示 Bug +6. Bug修复:优化上下文 Token 计算算法,修复聊天上下文超出限制时循环发送消息的 Bug +7. 功能修正:允许用户使用手机号码登录 +8. 功能优化:更新系统配置后同步更新服务端内存变量数据 +9. 功能优化:优化打包脚本,减少容器镜像大小 + ## v3.0.5 重磅功能更新!!! 新增函数插件支持,可以轻松地接入你的第三方插件服务,ChatGPT 自动帮您调用对应的函数完成任务。 diff --git a/api/core/types/config.go b/api/core/types/config.go index b7393c0f..148c2954 100644 --- a/api/core/types/config.go +++ b/api/core/types/config.go @@ -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 diff --git a/api/handler/admin/config_handler.go b/api/handler/admin/config_handler.go index 6cac766b..41791464 100644 --- a/api/handler/admin/config_handler.go +++ b/api/handler/admin/config_handler.go @@ -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) diff --git a/api/handler/sms_handler.go b/api/handler/sms_handler.go index 665baa73..597fd609 100644 --- a/api/handler/sms_handler.go +++ b/api/handler/sms_handler.go @@ -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}) } diff --git a/web/src/views/Register.vue b/web/src/views/Register.vue index ae40edfd..74bf670c 100644 --- a/web/src/views/Register.vue +++ b/web/src/views/Register.vue @@ -1,101 +1,111 @@ @@ -121,10 +131,12 @@ const formData = ref({ }) const formRef = ref(null) const enableMsg = ref(false) +const enableRegister = ref(true) httpGet('/api/sms/status').then(res => { - if (res.data === true) { - enableMsg.value = true + if (res.data) { + enableMsg.value = res.data['enabled_msg_service'] + enableRegister.value = res.data['enabled_register'] } }) @@ -166,76 +178,108 @@ const register = function () { //filter: blur(10px); /* 调整模糊程度,可以根据需要修改值 */ } -.main { - .contain { - position fixed - left 50% - top 40% - width 90% - max-width 400px - transform translate(-50%, -50%) - padding 20px 40px; - color #ffffff - border-radius 10px; - background rgba(255, 255, 255, 0.3) +.register-page { + display flex + justify-content center - .logo { - text-align center + .page-inner { + max-width 450px + height 100vh + display flex + justify-content center + align-items center - .el-image { - width 120px; + .contain { + padding 0 40px 20px 40px; + color #ffffff + border-radius 10px; + z-index 10 + background-color rgba(255, 255, 255, 0.3) + + .logo { + text-align center + + .el-image { + width 120px; + } } - } - .header { - width 100% - margin-bottom 24px - font-size 24px - color $white_v1 - letter-space 2px - text-align center - } + .header { + width 100% + margin-bottom 24px + font-size 24px + color $white_v1 + letter-space 2px + text-align center + } - .content { - width 100% - height: auto - border-radius 3px + .content { + width 100% + height: auto + border-radius 3px - .block { - margin-bottom 16px + .block { + margin-bottom 16px - .el-input__inner { - border 1px solid $gray-v6 !important + .el-input__inner { + border 1px solid $gray-v6 !important - .el-icon-user, .el-icon-lock { - font-size 20px + .el-icon-user, .el-icon-lock { + font-size 20px + } } } - } - .btn-row { - padding-top 10px; + .btn-row { + padding-top 10px; - .login-btn { - width 100% - font-size 16px - letter-spacing 2px + .login-btn { + width 100% + font-size 16px + letter-spacing 2px + } + } + + .text-line { + justify-content center + padding-top 10px; + font-size 14px; } } + } - .text-line { - justify-content center - padding-top 10px; - font-size 14px; + + .tip-result { + z-index 10 + } + + .footer { + color #ffffff; + + .container { + padding 20px; } } + } - .footer { - color #ffffff; +} + - .container { - padding 20px; +