From 76fce2a8c6006b3c75e84b7ea8a7dcb4e3bc020a Mon Sep 17 00:00:00 2001 From: Jeffrey Chen <78434827+TCOTC@users.noreply.github.com> Date: Wed, 27 Mar 2024 18:31:20 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=87=E6=8D=A2=E9=A1=B5=E7=AD=BE=E6=97=B6?= =?UTF-8?q?=E9=87=8D=E6=96=B0=E6=90=9C=E7=B4=A2=20#2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugin.json | 2 +- src/Search.vue | 28 ++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/plugin.json b/plugin.json index 4bf9d82..a5fea29 100644 --- a/plugin.json +++ b/plugin.json @@ -2,7 +2,7 @@ "name": "siyuan-plugin-hsr-mdzz2048-fork", "author": "TCOTC", "url": "https://github.com/TCOTC/siyuan-plugin-hsr-mdzz2048-fork", - "version": "0.1.9", + "version": "0.1.10", "minAppVersion": "2.9.8", "backends": ["windows", "linux", "darwin"], "frontends": ["desktop", "browser-desktop"], diff --git a/src/Search.vue b/src/Search.vue index 8f5b683..93968ca 100644 --- a/src/Search.vue +++ b/src/Search.vue @@ -55,6 +55,34 @@ function handleInput() { } + +// 监控当前页签,切换页签时重新搜索 +let previousDataId = null; + +function extractDataIds() { + const tabContainer = this.$refs.tabContainer; + const elements = tabContainer.querySelectorAll('.layout-tab-container > div:not(.fn__none)'); + + let currentDataId = ''; + elements.forEach(element => { + currentDataId = element.getAttribute('data-id'); + console.log(currentDataId); + }); + + if (previousDataId !== null && previousDataId !== currentDataId) { + highlightHitResult(searchText.value, true); + } + + previousDataId = currentDataId; +} + +setInterval(() => { + extractDataIds(); +}, 4000); + + + + // REF: https://juejin.cn/post/7199438741533376573 // 使用 [CSS 自定义高亮 API - Web API 接口参考 | MDN](https://developer.mozilla.org/zh-CN/docs/Web/API/CSS_Custom_Highlight_API) // 兼容性:Chrome、Edge (105+), Safari (17.2+), firefox (寄), Electron (思源使用的版本 > 28.0, 可以使用这个 API)