Skip to content

Commit

Permalink
切换页签时重新搜索 #2
Browse files Browse the repository at this point in the history
  • Loading branch information
TCOTC committed Mar 27, 2024
1 parent d413f0f commit 76fce2a
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
2 changes: 1 addition & 1 deletion plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
Expand Down
28 changes: 28 additions & 0 deletions src/Search.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 76fce2a

Please sign in to comment.