blog

Welcome to my blog!

标签 : GPU

log('\n %c Suka Theme (hexo-theme-suka) | © SukkaW | Verision 1.3.3 %c https://github.com/SukkaW/hexo-theme-suka \n', 'color: #fff; background: #444; padding:5px 0;', 'background: #bbb; padding:5px 0;'); (function() { 'use strict'; // 等待 DOM 加载完成 if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', initTocCollapse); } else { initTocCollapse(); } function initTocCollapse() { const tocContainer = document.getElementById('post-toc'); if (!tocContainer) { return; } // 找到所有有子目录的 level-1 和 level-2 项 const tocItems = tocContainer.querySelectorAll('.post-toc-item.post-toc-level-1, .post-toc-item.post-toc-level-2'); tocItems.forEach(function(item) { // 检查是否有子目录(包含 post-toc-child 的 ol) const hasChildren = item.querySelector('ol.post-toc-child') !== null; if (hasChildren) { // 添加标记类,用于 CSS 显示图标 item.classList.add('toc-has-children'); const link = item.querySelector('.post-toc-link'); if (link) { // 阻止默认的锚点跳转,改为展开/折叠 link.addEventListener('click', function(e) { // 如果用户按住 Ctrl/Cmd 或中键点击,则跳转 if (e.ctrlKey || e.metaKey || e.button === 1) { return; // 允许默认行为(跳转) } e.preventDefault(); e.stopPropagation(); // 切换展开/折叠状态 item.classList.toggle('toc-expanded'); }); // 允许通过双击链接文本跳转 link.addEventListener('dblclick', function(e) { const href = link.getAttribute('href'); if (href) { window.location.hash = href; } }); // 允许通过右键菜单跳转 link.addEventListener('contextmenu', function(e) { // 允许默认的右键菜单 return true; }); } } }); } })();