mirror of
https://github.com/yangjian102621/geekai.git
synced 2025-11-09 10:43:44 +08:00
系统设置页面功能完成
This commit is contained in:
@@ -19,8 +19,15 @@ func (s *Server) AddApiKeyHandle(c *gin.Context) {
|
||||
c.JSON(http.StatusBadRequest, nil)
|
||||
return
|
||||
}
|
||||
// 过滤已存在的 Key
|
||||
for _,key:=range s.Config.Chat.ApiKeys {
|
||||
if key.Value == data.ApiKey {
|
||||
c.JSON(http.StatusOK, types.BizVo{Code: types.Failed, Message: "API KEY 已存在"})
|
||||
return
|
||||
}
|
||||
}
|
||||
if len(data.ApiKey) > 20 {
|
||||
s.Config.Chat.ApiKeys = append(s.Config.Chat.ApiKeys, data.ApiKey)
|
||||
s.Config.Chat.ApiKeys = append(s.Config.Chat.ApiKeys, types.APIKey{Value: data.ApiKey})
|
||||
}
|
||||
|
||||
// 保存配置文件
|
||||
@@ -46,8 +53,9 @@ func (s *Server) RemoveApiKeyHandle(c *gin.Context) {
|
||||
}
|
||||
|
||||
for i, v := range s.Config.Chat.ApiKeys {
|
||||
if v == data.ApiKey {
|
||||
if v.Value == data.ApiKey {
|
||||
s.Config.Chat.ApiKeys = append(s.Config.Chat.ApiKeys[:i], s.Config.Chat.ApiKeys[i+1:]...)
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user