From 41d7afcf99790cf93d7501802e09972959d21e03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=85=AC=E6=98=8E?= <83812544+Ed1s0nZ@users.noreply.github.com> Date: Fri, 20 Feb 2026 18:10:29 +0800 Subject: [PATCH] Add files via upload --- internal/handler/config.go | 9 +++++++++ web/static/js/info-collect.js | 9 ++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/internal/handler/config.go b/internal/handler/config.go index efdd2543..47c799c5 100644 --- a/internal/handler/config.go +++ b/internal/handler/config.go @@ -854,6 +854,7 @@ func (h *ConfigHandler) saveConfig() error { updateAgentConfig(root, h.config.Agent.MaxIterations) updateMCPConfig(root, h.config.MCP) updateOpenAIConfig(root, h.config.OpenAI) + updateFOFAConfig(root, h.config.FOFA) updateKnowledgeConfig(root, h.config.Knowledge) // 更新外部MCP配置(使用external_mcp.go中的函数,同一包中可直接调用) // 读取原始配置以保持向后兼容 @@ -998,6 +999,14 @@ func updateOpenAIConfig(doc *yaml.Node, cfg config.OpenAIConfig) { setStringInMap(openaiNode, "model", cfg.Model) } +func updateFOFAConfig(doc *yaml.Node, cfg config.FofaConfig) { + root := doc.Content[0] + fofaNode := ensureMap(root, "fofa") + setStringInMap(fofaNode, "base_url", cfg.BaseURL) + setStringInMap(fofaNode, "email", cfg.Email) + setStringInMap(fofaNode, "api_key", cfg.APIKey) +} + func updateKnowledgeConfig(doc *yaml.Node, cfg config.KnowledgeConfig) { root := doc.Content[0] knowledgeNode := ensureMap(root, "knowledge") diff --git a/web/static/js/info-collect.js b/web/static/js/info-collect.js index a840a5e2..2783f8f9 100644 --- a/web/static/js/info-collect.js +++ b/web/static/js/info-collect.js @@ -952,10 +952,17 @@ async function batchScanSelectedFofaRows() { const title = (p.query ? `FOFA 批量扫描:${p.query}` : 'FOFA 批量扫描').slice(0, 80); try { + // 不强制切换到“信息收集”角色:沿用当前已选角色;若为默认则传空字符串交给后端走默认逻辑 + let role = ''; + if (typeof getCurrentRole === 'function') { + try { role = getCurrentRole() || ''; } catch (e) { /* ignore */ } + } + if (role === '默认') role = ''; + const resp = await apiFetch('/api/batch-tasks', { method: 'POST', headers: { 'Content-Type': 'application/json' }, - body: JSON.stringify({ title, tasks, role: '信息收集' }) + body: JSON.stringify({ title, tasks, role }) }); const result = await resp.json().catch(() => ({})); if (!resp.ok) {