From 25678bf86611f398e7778f17c7c685cea25526d0 Mon Sep 17 00:00:00 2001 From: thzxx Date: Fri, 12 Jun 2026 13:02:32 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20SearXNG=20max=5Fresults=20=E4=BB=A5?= =?UTF-8?q?=E9=9D=A2=E6=9D=BF=E9=85=8D=E7=BD=AE=E4=B8=BA=E5=87=86=EF=BC=8C?= =?UTF-8?q?=E4=B8=8D=E5=86=8D=E4=B8=8EAI=E4=BC=A0=E5=85=A5=E6=AF=94?= =?UTF-8?q?=E8=BE=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/tool-handlers-system.ts | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/main/tool-handlers-system.ts b/src/main/tool-handlers-system.ts index b5238ac..8f60288 100644 --- a/src/main/tool-handlers-system.ts +++ b/src/main/tool-handlers-system.ts @@ -456,7 +456,6 @@ async function handleWebSearchSearxng( const cfgTimeRange = getSetting('searxng_time_range', ''); const effectiveTimeRange = timeRange || cfgTimeRange; const cfgMaxResults = getSetting('searxng_max_results', 20); - const effectiveMaxResults = Math.min(maxResults, cfgMaxResults); const format = getSetting('searxng_format', 'json'); const isHtml = format === 'html'; @@ -489,8 +488,8 @@ async function handleWebSearchSearxng( if (isHtml) { const html = await resp.text(); const text = htmlToText(html); - const truncated = effectiveMaxResults > 0 && text.length > effectiveMaxResults * 500; - const content = truncated ? text.slice(0, effectiveMaxResults * 500) + '\n...(已截断)' : text; + const truncated = cfgMaxResults > 0 && text.length > cfgMaxResults * 500; + const content = truncated ? text.slice(0, cfgMaxResults * 500) + '\n...(已截断)' : text; sendLog('success', `🔍 SearXNG HTML 完成`, `${text.length} 字符`); return { success: true, @@ -518,7 +517,7 @@ async function handleWebSearchSearxng( unresponsive_engines?: Array<[string, string]>; }; - const rawResults = (data.results || []).slice(0, effectiveMaxResults); + const rawResults = (data.results || []).slice(0, cfgMaxResults); if (rawResults.length === 0) { return { success: false, error: 'SearXNG 未返回任何结果,请尝试其他关键词或调整搜索引擎配置' }; } @@ -554,7 +553,7 @@ async function handleWebSearchSearxng( weight: 80, reachable: true, })), - effectiveMaxResults, + cfgMaxResults, false, engineStats );