diff --git a/api/go/core/app_server.go b/api/go/core/app_server.go index f6828e2d..ab1d94c3 100644 --- a/api/go/core/app_server.go +++ b/api/go/core/app_server.go @@ -137,8 +137,7 @@ func authorizeMiddleware(s *AppServer) gin.HandlerFunc { if c.Request.URL.Path == "/api/user/login" || c.Request.URL.Path == "/api/admin/login" || c.Request.URL.Path == "/api/user/register" || - c.Request.URL.Path == "/api/apikey/add" || - c.Request.URL.Path == "/api/apikey/list" { + c.Request.URL.Path == "/api/config/get" { c.Next() return } diff --git a/api/go/core/types/config.go b/api/go/core/types/config.go index 4b55f1b7..3b623da1 100644 --- a/api/go/core/types/config.go +++ b/api/go/core/types/config.go @@ -49,6 +49,4 @@ type SystemConfig struct { UserInitCalls int `json:"user_init_calls"` // 新用户注册默认总送多少次调用 } -var GptModels = []string{"gpt-3.5-turbo", "gpt-3.5-turbo-16k", "gpt-3.5-turbo-0613", "gpt-3.5-turbo-16k-0613", "gpt-4", "gpt-4-0613", "gpt-4-32k", "gpt-4-32k-0613"} - const UserInitCalls = 1000 diff --git a/api/go/handler/config_handler.go b/api/go/handler/admin/config_handler.go similarity index 85% rename from api/go/handler/config_handler.go rename to api/go/handler/admin/config_handler.go index 497216a8..1ddf837c 100644 --- a/api/go/handler/config_handler.go +++ b/api/go/handler/admin/config_handler.go @@ -1,8 +1,9 @@ -package handler +package admin import ( "chatplus/core" "chatplus/core/types" + "chatplus/handler" "chatplus/store/model" "chatplus/utils" "chatplus/utils/resp" @@ -12,14 +13,14 @@ import ( ) type ConfigHandler struct { - BaseHandler + handler.BaseHandler db *gorm.DB } func NewConfigHandler(app *core.AppServer, db *gorm.DB) *ConfigHandler { - handler := ConfigHandler{db: db} - handler.App = app - return &handler + h := ConfigHandler{db: db} + h.App = app + return &h } func (h *ConfigHandler) Update(c *gin.Context) { @@ -71,8 +72,3 @@ func (h *ConfigHandler) Get(c *gin.Context) { resp.SUCCESS(c, m) } - -// AllGptModels 获取所有的 GPT 模型 -func (h *ConfigHandler) AllGptModels(c *gin.Context) { - resp.SUCCESS(c, types.GptModels) -} diff --git a/api/go/main.go b/api/go/main.go index f7785dfb..cc08532e 100644 --- a/api/go/main.go +++ b/api/go/main.go @@ -85,7 +85,7 @@ func main() { fx.Provide(handler.NewChatRoleHandler), fx.Provide(handler.NewUserHandler), fx.Provide(handler.NewChatHandler), - fx.Provide(handler.NewConfigHandler), + fx.Provide(admin.NewConfigHandler), fx.Provide(admin.NewAdminHandler), fx.Provide(admin.NewApiKeyHandler), @@ -117,13 +117,13 @@ func main() { group.GET("tokens", h.Tokens) group.GET("stop", h.StopGenerate) }), - fx.Invoke(func(s *core.AppServer, h *handler.ConfigHandler) { - group := s.Engine.Group("/api/config/") + + // + fx.Invoke(func(s *core.AppServer, h *admin.ConfigHandler) { + group := s.Engine.Group("/api/admin/config/") group.POST("update", h.Update) group.GET("get", h.Get) - group.GET("models", h.AllGptModels) }), - fx.Invoke(func(s *core.AppServer, h *admin.ManagerHandler) { group := s.Engine.Group("/api/admin/") group.POST("login", h.Login) diff --git a/web/src/views/ChatPlus.vue b/web/src/views/ChatPlus.vue index f9620b90..cee1e7a3 100644 --- a/web/src/views/ChatPlus.vue +++ b/web/src/views/ChatPlus.vue @@ -200,7 +200,8 @@ import { Close, Delete, Edit, - Plus, Promotion, + Plus, + Promotion, RefreshRight, Search, Tools, @@ -270,7 +271,7 @@ if (!user.value) { }); // 加载系统配置 - httpGet('/api/config/get?key=system').then(res => { + httpGet('/api/admin/config/get?key=system').then(res => { title.value = res.data.title; models.value = res.data.models; }).catch(e => { @@ -731,8 +732,10 @@ $borderColor = #4676d0; height: 100%; // left side + .el-aside { background-color: $sideBgColor; + .title-box { padding: 6px 10px; display: flex; diff --git a/web/src/views/admin/Admin.vue b/web/src/views/admin/Admin.vue index d4f59d08..ee78f2b5 100644 --- a/web/src/views/admin/Admin.vue +++ b/web/src/views/admin/Admin.vue @@ -94,16 +94,15 @@