feat: Implement the ChatGPT Owner Demotion Console with new frontend and backend components.

This commit is contained in:
2026-02-05 03:13:30 +08:00
parent 61712cf4fb
commit 2bccb06359
6 changed files with 454 additions and 13 deletions

View File

@@ -166,6 +166,9 @@ func startServer(cfg *config.Config) {
mux.HandleFunc("/api/codex-proxy", api.CORS(api.HandleCodexProxies))
mux.HandleFunc("/api/codex-proxy/test", api.CORS(api.HandleCodexProxies))
// Owner 降级 API
mux.HandleFunc("/api/demote/owner", api.CORS(api.HandleDemoteOwner))
// 嵌入的前端静态文件
if web.IsEmbedded() {
webFS := web.GetFileSystem()
@@ -237,6 +240,7 @@ func handleConfig(w http.ResponseWriter, r *http.Request) {
"team_reg_proxy_test_ip": getTeamRegProxyTestIP(),
"site_name": config.Global.SiteName,
"auth_method": config.Global.AuthMethod,
"demote_after_use": config.Global.DemoteAfterUse,
"mail_services_count": len(config.Global.MailServices),
"mail_services": config.Global.MailServices,
})
@@ -244,16 +248,17 @@ func handleConfig(w http.ResponseWriter, r *http.Request) {
case http.MethodPut:
// 更新配置
var req struct {
S2AApiBase *string `json:"s2a_api_base"`
S2AAdminKey *string `json:"s2a_admin_key"`
Concurrency *int `json:"concurrency"`
Priority *int `json:"priority"`
GroupIDs []int `json:"group_ids"`
ProxyEnabled *bool `json:"proxy_enabled"`
DefaultProxy *string `json:"default_proxy"`
TeamRegProxy *string `json:"team_reg_proxy"`
SiteName *string `json:"site_name"`
AuthMethod *string `json:"auth_method"`
S2AApiBase *string `json:"s2a_api_base"`
S2AAdminKey *string `json:"s2a_admin_key"`
Concurrency *int `json:"concurrency"`
Priority *int `json:"priority"`
GroupIDs []int `json:"group_ids"`
ProxyEnabled *bool `json:"proxy_enabled"`
DefaultProxy *string `json:"default_proxy"`
TeamRegProxy *string `json:"team_reg_proxy"`
SiteName *string `json:"site_name"`
AuthMethod *string `json:"auth_method"`
DemoteAfterUse *bool `json:"demote_after_use"`
}
if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
api.Error(w, http.StatusBadRequest, "请求格式错误")
@@ -296,6 +301,9 @@ func handleConfig(w http.ResponseWriter, r *http.Request) {
if req.AuthMethod != nil {
config.Global.AuthMethod = *req.AuthMethod
}
if req.DemoteAfterUse != nil {
config.Global.DemoteAfterUse = *req.DemoteAfterUse
}
// 保存到数据库 (实时生效)
if err := config.Update(config.Global); err != nil {