Add files via upload

This commit is contained in:
公明
2026-07-11 11:40:09 +08:00
committed by GitHub
parent d1d67b07d3
commit 9ac5fd33ec
3 changed files with 8 additions and 26 deletions
+4 -22
View File
@@ -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))
}
+1 -1
View File
@@ -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 等大段文本塞进列表上下文) ---
+3 -3
View File
@@ -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()