mirror of
https://github.com/yangjian102621/geekai.git
synced 2025-12-06 08:16:07 +08:00
将 license 存储到数据库
This commit is contained in:
@@ -171,5 +171,6 @@ type SystemConfig struct {
|
||||
EmailWhiteList []string `json:"email_white_list"` // 邮箱白名单列表
|
||||
TranslateModelId int `json:"translate_model_id"` // 用来做提示词翻译的大模型 id
|
||||
MaxFileSize int `json:"max_file_size"` // 最大文件大小,单位:MB
|
||||
License string `json:"license"` // License
|
||||
|
||||
}
|
||||
|
||||
@@ -131,8 +131,17 @@ func (h *ConfigHandler) Active(c *gin.Context) {
|
||||
resp.ERROR(c, err.Error())
|
||||
return
|
||||
}
|
||||
h.App.SysConfig.License = data.License
|
||||
|
||||
// 将 license 写入数据库
|
||||
err = h.DB.Model(&model.Config{}).Where("marker", "system").UpdateColumn("config_json", utils.JsonEncode(h.App.SysConfig)).Error
|
||||
if err != nil {
|
||||
resp.ERROR(c, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
resp.SUCCESS(c)
|
||||
|
||||
resp.SUCCESS(c, info.HostID)
|
||||
}
|
||||
|
||||
// GetLicense 获取 License 信息
|
||||
|
||||
@@ -13,6 +13,9 @@ import (
|
||||
"geekai/core"
|
||||
"geekai/core/types"
|
||||
"geekai/store"
|
||||
"geekai/store/model"
|
||||
"geekai/utils"
|
||||
"gorm.io/gorm"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
@@ -22,16 +25,27 @@ import (
|
||||
|
||||
type LicenseService struct {
|
||||
config types.ApiConfig
|
||||
db *gorm.DB
|
||||
levelDB *store.LevelDB
|
||||
license *types.License
|
||||
urlWhiteList []string
|
||||
machineId string
|
||||
}
|
||||
|
||||
func NewLicenseService(server *core.AppServer, levelDB *store.LevelDB) *LicenseService {
|
||||
func NewLicenseService(server *core.AppServer, levelDB *store.LevelDB, db *gorm.DB) *LicenseService {
|
||||
var license types.License
|
||||
var machineId string
|
||||
_ = levelDB.Get(types.LicenseKey, &license)
|
||||
err := levelDB.Get(types.LicenseKey, &license)
|
||||
logger.Infof("License: %+v", server.SysConfig)
|
||||
if err != nil {
|
||||
var cfg model.Config
|
||||
db.Where("marker", "system").First(&cfg)
|
||||
var sysConfig types.SystemConfig
|
||||
if err := utils.JsonDecode(cfg.Config, &sysConfig); err == nil {
|
||||
license.Key = sysConfig.License
|
||||
license.IsActive = true
|
||||
}
|
||||
}
|
||||
info, err := host.Info()
|
||||
if err == nil {
|
||||
machineId = info.HostID
|
||||
|
||||
@@ -142,7 +142,7 @@ func (s *Service) Create(task types.SunoTask) (RespVo, error) {
|
||||
|
||||
var res RespVo
|
||||
apiURL := fmt.Sprintf("%s/suno/submit/music", apiKey.ApiURL)
|
||||
logger.Debugf("API URL: %s, request body: %+v", apiURL, reqBody)
|
||||
logger.Debugf("API URL: %s, request body: %s", apiURL, utils.JsonEncode(reqBody))
|
||||
r, err := req.C().R().
|
||||
SetHeader("Authorization", "Bearer "+apiKey.Value).
|
||||
SetBody(reqBody).
|
||||
|
||||
@@ -90,7 +90,7 @@
|
||||
.song {
|
||||
display flex
|
||||
padding 10px
|
||||
background-color #252020
|
||||
background-color var(--el-bg-color)
|
||||
border-radius 10px
|
||||
margin-bottom 10px
|
||||
font-size 14px
|
||||
@@ -109,6 +109,7 @@
|
||||
display flex
|
||||
margin-left 10px
|
||||
align-items center
|
||||
color var(--el-color-primary)
|
||||
}
|
||||
|
||||
.el-button--info {
|
||||
@@ -347,7 +348,9 @@
|
||||
|
||||
.task {
|
||||
height 100px
|
||||
background-color #2A2525
|
||||
background-color var(--el-bg-color)
|
||||
border: 1px solid var(--el-border-color-light);
|
||||
border-radius 5px
|
||||
display flex
|
||||
margin-bottom 10px
|
||||
.left {
|
||||
@@ -358,7 +361,7 @@
|
||||
width 320px
|
||||
.title {
|
||||
font-size 14px
|
||||
color #e1e1e1
|
||||
color var(--el-text-color-primary)
|
||||
white-space: nowrap; /* 防止文字换行 */
|
||||
overflow: hidden; /* 隐藏溢出的内容 */
|
||||
text-overflow: ellipsis; /* 用省略号表示溢出的内容 */
|
||||
|
||||
Reference in New Issue
Block a user