From 0eba964a5afabae6ed9e33512324cdb1ab98cd73 Mon Sep 17 00:00:00 2001 From: cxykevin Date: Tue, 27 Aug 2024 22:39:25 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=BB=E9=A2=98=E5=B0=8F=E4=BC=98=E5=8C=96?= =?UTF-8?q?=20(#23)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewed-on: https://git.hmtsai.cn/study-area-cn/study-area-cn/pulls/23 --- theme/js/page.js | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/theme/js/page.js b/theme/js/page.js index 9570bab..53473b8 100644 --- a/theme/js/page.js +++ b/theme/js/page.js @@ -2,6 +2,26 @@ if (window.innerWidth > 640) { // 自动展开导航栏 document.getElementById("toc-drawer").setAttribute('open', true); } +// 细节修复 +function update_text() { + console.log(1) + // 修复 table + var tables = document.getElementsByTagName("table") + if (tables != undefined) { + for (let i = 0; i < tables.length; i++) { + tables[i].parentNode.classList.add('mdui-table'); + } + } + + // 修复 hr + var hrs = document.getElementsByTagName("hr") + if (hrs != undefined) { + for (let i = 0; i < hrs.length; i++) { + hrs[i].replaceWith(document.createElement("mdui-divider")); + } + } +} + function prevPage() { var link = document.getElementById("helper_prevpage").href; @@ -71,6 +91,9 @@ function changePage(url) { // 刷新高亮 hljs.highlightAll(); + + // 修复内容 + update_text(); } }; // 发送 XHR @@ -83,3 +106,5 @@ window.addEventListener('popstate', function (event) { console.log('pop state:', window.location.protocol + "//" + window.location.host + location.pathname); changePage(window.location.protocol + "//" + window.location.host + location.pathname); }); + +update_text(); \ No newline at end of file