Skip to content

Commit

Permalink
🛠优化文档目录滚动逻辑
Browse files Browse the repository at this point in the history
- 移除了对 idList 的全局声明,改为在函数内部直接定义
- 删除了对 idList 的缓存逻辑,每次调用时重新获取元素
  • Loading branch information
0xcaffebabe committed Dec 12, 2024
1 parent 28b9741 commit ca3af5a
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/pages/doc/contents/ContentsList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,9 @@ import DocService from "@/service/DocService";
let idList :NodeListOf<Element> | null= null
function highlightHeading(instance: InstanceType<typeof ContentList>) {
if (!idList){
idList = document.querySelectorAll(
".main.markdown-section h1, .main.markdown-section h2, .main.markdown-section h3, .main.markdown-section h4, .main.markdown-section h5, .main.markdown-section h6"
);
}
const idList = document.querySelectorAll(
".main.markdown-section h1, .main.markdown-section h2, .main.markdown-section h3, .main.markdown-section h4, .main.markdown-section h5, .main.markdown-section h6"
);
let node = null;
// 滚动到顶部特殊处理
if (window.scrollY == 0) {
Expand Down

0 comments on commit ca3af5a

Please sign in to comment.