From 0bfb35b9786fd07f155c96eaf1eeca2b8909fda0 Mon Sep 17 00:00:00 2001 From: Lan Hui <1348141770@qq.com> Date: Tue, 27 Aug 2024 11:29:09 +0800 Subject: [PATCH] Make translation tooltip work --- app/static/js/highlight.js | 6 +++--- app/templates/userpage_get.html | 1 + requirements.txt | 4 ++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/app/static/js/highlight.js b/app/static/js/highlight.js index d2c37a8..c239eaa 100644 --- a/app/static/js/highlight.js +++ b/app/static/js/highlight.js @@ -114,12 +114,12 @@ function showWordMeaning(event) { return; } - - tooltip.textContent = data.translation || '没有找到该单词的中文意思'; tooltip.style.left = `${tooltipX}px`; tooltip.style.top = `${tooltipY}px`; tooltip.style.display = 'block'; + tooltip.style.position = 'absolute'; + tooltip.style.background = 'yellow'; // 可以在这里添加点击事件监听器来隐藏tooltip,但注意避免内存泄漏 document.addEventListener('click', function handler(e) { @@ -141,4 +141,4 @@ function addClickEventToHighlightedWords() { }); } -showBtnHandler(); \ No newline at end of file +showBtnHandler(); diff --git a/app/templates/userpage_get.html b/app/templates/userpage_get.html index 8daa344..60598df 100644 --- a/app/templates/userpage_get.html +++ b/app/templates/userpage_get.html @@ -107,6 +107,7 @@