From faca995ceff698d174cbcc128c8105ec2756abbc Mon Sep 17 00:00:00 2001 From: fanlumaster <1730976608@qq.com> Date: Wed, 28 Jan 2026 22:01:50 +0800 Subject: [PATCH] [feat]: Send msg to cpp end when left click cand item --- .../candwnd/vertical_candidate_window_dark.html | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/ui-html/webview2/candwnd/vertical_candidate_window_dark.html b/ui-html/webview2/candwnd/vertical_candidate_window_dark.html index a93b2004..5f3c1772 100644 --- a/ui-html/webview2/candwnd/vertical_candidate_window_dark.html +++ b/ui-html/webview2/candwnd/vertical_candidate_window_dark.html @@ -206,6 +206,21 @@ if (!e.target.closest('.context-menu')) { hideContextMenu(); } + + const candElement = e.target.closest('.cand'); + if (candElement && e.button === 0) { + const candNoElement = candElement.querySelector('.cand-no'); + const candIndex = candNoElement ? Number(candNoElement.textContent.trim()) : null; + if (candIndex !== null) { + console.log('Candidate left clicked:', candIndex); + try { + window.chrome.webview.postMessage(JSON.stringify({ type: 'candidate', data: Number(candIndex) })); + // TODO: 考虑一下,这里要不要也去做一下 html 界面的隐藏。 + } catch (e) { + console.error('Failed to send message:', e); + } + } + } }); document.addEventListener('mousemove', function () {