mirror of
https://gitee.com/blackfox/geekai.git
synced 2024-12-02 12:17:42 +08:00
opt: add enabled_msg_service config var to system config database
This commit is contained in:
parent
48c4789505
commit
2ee4db5e48
@ -6,20 +6,19 @@ import (
|
||||
)
|
||||
|
||||
type AppConfig struct {
|
||||
Path string `toml:"-"`
|
||||
Listen string
|
||||
Session Session
|
||||
ProxyURL string
|
||||
MysqlDns string // mysql 连接地址
|
||||
Manager Manager // 后台管理员账户信息
|
||||
StaticDir string // 静态资源目录
|
||||
StaticUrl string // 静态资源 URL
|
||||
Redis RedisConfig // redis 连接信息
|
||||
ApiConfig ChatPlusApiConfig // ChatPlus API authorization configs
|
||||
AesEncryptKey string
|
||||
SmsConfig AliYunSmsConfig // AliYun send message service config
|
||||
StartWechatBot bool // 是否启动微信机器人
|
||||
EnabledMsgService bool // 是否启用短信服务
|
||||
Path string `toml:"-"`
|
||||
Listen string
|
||||
Session Session
|
||||
ProxyURL string
|
||||
MysqlDns string // mysql 连接地址
|
||||
Manager Manager // 后台管理员账户信息
|
||||
StaticDir string // 静态资源目录
|
||||
StaticUrl string // 静态资源 URL
|
||||
Redis RedisConfig // redis 连接信息
|
||||
ApiConfig ChatPlusApiConfig // ChatPlus API authorization configs
|
||||
AesEncryptKey string
|
||||
SmsConfig AliYunSmsConfig // AliYun send message service config
|
||||
StartWechatBot bool // 是否启动微信机器人
|
||||
}
|
||||
|
||||
type ChatPlusApiConfig struct {
|
||||
@ -85,9 +84,10 @@ 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"` // 新用户注册默认总送多少次调用
|
||||
EnabledRegister bool `json:"enabled_register"`
|
||||
Title string `json:"title"`
|
||||
AdminTitle string `json:"admin_title"`
|
||||
Models []string `json:"models"`
|
||||
UserInitCalls int `json:"user_init_calls"` // 新用户注册默认总送多少次调用
|
||||
EnabledRegister bool `json:"enabled_register"`
|
||||
EnabledMsgService bool `json:"enabled_msg_service"`
|
||||
}
|
||||
|
@ -66,5 +66,5 @@ type statusVo struct {
|
||||
|
||||
// Status check if the message service is enabled
|
||||
func (h *SmsHandler) Status(c *gin.Context) {
|
||||
resp.SUCCESS(c, statusVo{EnabledMsgService: h.App.Config.EnabledMsgService, EnabledRegister: h.App.SysConfig.EnabledRegister})
|
||||
resp.SUCCESS(c, statusVo{EnabledMsgService: h.App.SysConfig.EnabledMsgService, EnabledRegister: h.App.SysConfig.EnabledRegister})
|
||||
}
|
||||
|
@ -58,7 +58,7 @@ func (h *UserHandler) Register(c *gin.Context) {
|
||||
|
||||
// 检查验证码
|
||||
key := CodeStorePrefix + data.Mobile
|
||||
if h.App.Config.EnabledMsgService {
|
||||
if h.App.SysConfig.EnabledMsgService {
|
||||
var code int
|
||||
err := h.levelDB.Get(key, &code)
|
||||
if err != nil || code != data.Code {
|
||||
@ -117,7 +117,7 @@ func (h *UserHandler) Register(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
if h.App.Config.EnabledMsgService {
|
||||
if h.App.SysConfig.EnabledMsgService {
|
||||
_ = h.levelDB.Delete(key) // 注册成功,删除短信验证码
|
||||
}
|
||||
resp.SUCCESS(c, user)
|
||||
|
@ -49,7 +49,7 @@
|
||||
</el-input>
|
||||
</div>
|
||||
|
||||
<div class="block" v-if="enableMsg">
|
||||
<div class="block">
|
||||
<el-input placeholder="手机号码"
|
||||
size="large" maxlength="11"
|
||||
v-model="formData.mobile"
|
||||
@ -184,6 +184,7 @@ const register = function () {
|
||||
|
||||
.page-inner {
|
||||
max-width 450px
|
||||
min-width 360px
|
||||
height 100vh
|
||||
display flex
|
||||
justify-content center
|
||||
@ -191,6 +192,7 @@ const register = function () {
|
||||
|
||||
.contain {
|
||||
padding 0 40px 20px 40px;
|
||||
width 100%
|
||||
color #ffffff
|
||||
border-radius 10px;
|
||||
z-index 10
|
||||
|
@ -12,7 +12,10 @@
|
||||
<el-form-item label="注册赠送次数" prop="init_calls">
|
||||
<el-input v-model.number="system['user_init_calls']" placeholder="新用户注册赠送对话次数"/>
|
||||
</el-form-item>
|
||||
<el-form-item label="开放用户注册" prop="init_calls">
|
||||
<el-form-item label="短信验证服务" prop="enabled_msg_service">
|
||||
<el-switch v-model="system['enabled_msg_service']"/>
|
||||
</el-form-item>
|
||||
<el-form-item label="开放用户注册" prop="enabled_register">
|
||||
<el-switch v-model="system['enabled_register']"/>
|
||||
</el-form-item>
|
||||
<el-alert type="info" show-icon :closable="false">
|
||||
|
Loading…
Reference in New Issue
Block a user