From 9ac5fd33ecaea40ffa19b60a9bbf7b42a707940d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=85=AC=E6=98=8E?= <83812544+Ed1s0nZ@users.noreply.github.com> Date: Sat, 11 Jul 2026 11:40:09 +0800 Subject: [PATCH] Add files via upload --- internal/handler/auth.go | 26 ++++---------------------- internal/handler/batch_task_mcp.go | 2 +- internal/handler/config.go | 6 +++--- 3 files changed, 8 insertions(+), 26 deletions(-) diff --git a/internal/handler/auth.go b/internal/handler/auth.go index b2ce9ee9..4157115e 100644 --- a/internal/handler/auth.go +++ b/internal/handler/auth.go @@ -170,28 +170,10 @@ func (h *AuthHandler) ChangePassword(c *gin.Context) { return } - if session.UserID == "" || session.UserID == "admin" { - if err := config.PersistAuthPassword(h.configPath, newPassword); err != nil { - if h.logger != nil { - h.logger.Error("保存新密码失败", zap.Error(err)) - } - c.JSON(http.StatusInternalServerError, gin.H{"error": "保存新密码失败,请重试"}) - return - } - - if err := h.manager.UpdateConfig(newPassword, h.config.Auth.SessionDurationHours); err != nil { - if h.logger != nil { - h.logger.Error("更新认证配置失败", zap.Error(err)) - } - c.JSON(http.StatusInternalServerError, gin.H{"error": "更新认证配置失败"}) - return - } - - h.config.Auth.Password = newPassword - h.config.Auth.GeneratedPassword = "" - h.config.Auth.GeneratedPasswordPersisted = false - h.config.Auth.GeneratedPasswordPersistErr = "" - } else if err := h.manager.UpdateUserPassword(session.UserID, newPassword); err != nil { + if session.UserID == "" { + session.UserID = "admin" + } + if err := h.manager.UpdateUserPassword(session.UserID, newPassword); err != nil { if h.logger != nil { h.logger.Error("更新用户密码失败", zap.Error(err)) } diff --git a/internal/handler/batch_task_mcp.go b/internal/handler/batch_task_mcp.go index 3c714901..fbcce38b 100644 --- a/internal/handler/batch_task_mcp.go +++ b/internal/handler/batch_task_mcp.go @@ -664,7 +664,7 @@ schedule_mode 为 cron 时必须提供有效 cron_expr;为 manual 时会清除 return batchMCPJSONResult(queue) }) - logger.Info("批量任务 MCP 工具已注册", zap.Int("count", 12)) + logger.Debug("批量任务 MCP 工具已注册", zap.Int("count", 12)) } // --- batch_task_list 精简结构(避免把每条子任务的 result 等大段文本塞进列表上下文) --- diff --git a/internal/handler/config.go b/internal/handler/config.go index fa4463db..9087939f 100644 --- a/internal/handler/config.go +++ b/internal/handler/config.go @@ -1362,7 +1362,7 @@ func (h *ConfigHandler) ApplyConfig(c *gin.Context) { c.JSON(http.StatusInternalServerError, gin.H{"error": "初始化知识库失败: " + err.Error()}) return } - h.logger.Info("知识库动态初始化完成,工具已注册") + h.logger.Debug("知识库动态初始化完成,工具已注册") } // 检查嵌入模型配置是否变更(需要在锁外执行,避免阻塞) @@ -1441,10 +1441,10 @@ func (h *ConfigHandler) ApplyConfig(c *gin.Context) { c.JSON(http.StatusInternalServerError, gin.H{"error": "重新加载工具配置失败: " + err.Error()}) return } - h.logger.Info("已从 tools 目录重新加载工具配置", zap.Int("tools_count", len(h.config.Security.Tools))) + h.logger.Debug("已从 tools 目录重新加载工具配置", zap.Int("tools_count", len(h.config.Security.Tools))) // 重新注册工具(根据新的启用状态) - h.logger.Info("重新注册工具") + h.logger.Debug("重新注册工具") // 清空MCP服务器中的工具 h.mcpServer.ClearTools()