diff --git a/web/static/js/info-collect.js b/web/static/js/info-collect.js index 99b19f2e..deacce81 100644 --- a/web/static/js/info-collect.js +++ b/web/static/js/info-collect.js @@ -315,7 +315,7 @@ function renderFofaResults(payload) { - + @@ -401,7 +401,7 @@ function showInlineToast(text) { setTimeout(() => toast.remove(), 1200); } -function scanFofaRow(encodedRowJson) { +function scanFofaRow(encodedRowJson, clickEvent) { let row = {}; try { row = JSON.parse(decodeURIComponent(encodedRowJson)); @@ -416,39 +416,46 @@ function scanFofaRow(encodedRowJson) { return; } - // 切换到对话页并发送消息 + // 切换到对话页并发送消息(每次点击都新建会话,避免发到历史会话) if (typeof switchPage === 'function') { switchPage('chat'); } else { window.location.hash = 'chat'; } - // 尽量切到“信息收集”角色(如果存在) - try { - if (typeof selectRole === 'function') { - selectRole('信息收集'); - } else if (typeof handleRoleChange === 'function') { - handleRoleChange('信息收集'); - } - } catch (e) { - // ignore - } - const message = buildScanMessage(target, row); + const autoSend = !!(clickEvent && (clickEvent.ctrlKey || clickEvent.metaKey)); + + setTimeout(async () => { + // 新建会话:必须等待其完成,否则它会在后续把输入框清空 + try { + if (typeof startNewConversation === 'function') { + const maybePromise = startNewConversation(); + if (maybePromise && typeof maybePromise.then === 'function') { + await maybePromise; + } + } + } catch (e) { + // ignore + } - setTimeout(() => { const input = document.getElementById('chat-input'); if (input) { input.value = message; // 触发自动高度调整(chat.js 里如果监听 input) input.dispatchEvent(new Event('input', { bubbles: true })); + input.focus(); } - if (typeof sendMessage === 'function') { - sendMessage(); + if (autoSend) { + if (typeof sendMessage === 'function') { + sendMessage(); + } else { + alert('未找到 sendMessage(),请刷新页面后重试'); + } } else { - alert('未找到 sendMessage(),请刷新页面后重试'); + showInlineToast('已填入对话输入框,可编辑后发送'); } - }, 200); + }, 250); } function buildScanMessage(target, row) {