From 83299dfd2fe858e4d9d56d480780627f770b17b3 Mon Sep 17 00:00:00 2001 From: Jerry Date: Tue, 15 Dec 2020 18:52:58 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=BE=A9tabs=20=E6=A8=99?= =?UTF-8?q?=E7=B0=BD=E5=A4=96=E6=8C=82=E8=A8=AD=E7=88=B2-1=E6=99=82?= =?UTF-8?q?=EF=BC=8C=E6=8C=89=E9=88=95=E9=BB=9E=E6=93=8A=E6=B2=92=E5=8F=8D?= =?UTF-8?q?=E6=87=89=E7=9A=84bugs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- layout/includes/third-party/comments/twikoo.pug | 4 ++-- layout/includes/third-party/comments/valine.pug | 2 +- package.json | 2 +- source/js/main.js | 11 ++++++----- source/js/tw_cn.js | 5 +++-- 5 files changed, 13 insertions(+), 11 deletions(-) diff --git a/layout/includes/third-party/comments/twikoo.pug b/layout/includes/third-party/comments/twikoo.pug index 5a18d17..6dac48d 100644 --- a/layout/includes/third-party/comments/twikoo.pug +++ b/layout/includes/third-party/comments/twikoo.pug @@ -23,11 +23,11 @@ script. const loadTwikoo = (bool = false) => { if (typeof twikoo === 'object') { init() - bool && $countDom && setTimeout(()=>{getCount()},0) + bool && $countDom && setTimeout(getCount,0) } else { getScript('!{theme.CDN.twikoo}').then(()=> { init() - bool && $countDom && setTimeout(()=>{getCount()},0) + bool && $countDom && setTimeout(getCount,0) }) } } diff --git a/layout/includes/third-party/comments/valine.pug b/layout/includes/third-party/comments/valine.pug index 8bb75ae..5ca95bc 100644 --- a/layout/includes/third-party/comments/valine.pug +++ b/layout/includes/third-party/comments/valine.pug @@ -41,7 +41,7 @@ script. if ('!{theme.comments.use[0]}' === 'Valine' || !!{theme.comments.lazyload}) { if (!{theme.comments.lazyload}) btf.loadComment(document.querySelector('#vcomment'),loadValine) - else setTimeout(() => loadValine(), 0) + else setTimeout(loadValine, 0) } else { function loadOtherComment () { loadValine() diff --git a/package.json b/package.json index 417a7c9..3039164 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "hexo-theme-butterfly", - "version": "3.4.0", + "version": "3.4.1", "description": "A Simple and Card UI Design theme for Hexo", "main": "package.json", "scripts": { diff --git a/source/js/main.js b/source/js/main.js index 565749c..15a8081 100644 --- a/source/js/main.js +++ b/source/js/main.js @@ -471,7 +471,7 @@ document.addEventListener('DOMContentLoaded', function () { const currentActive = $tocLink[currentIndex] currentActive.classList.add('active') - setTimeout(function () { + setTimeout(() => { autoScrollToc(currentActive) }, 0) @@ -626,7 +626,7 @@ document.addEventListener('DOMContentLoaded', function () { */ const addRuntime = () => { const $runtimeCount = document.getElementById('runtimeshow') - if ($runtimeCount !== null) { + if ($runtimeCount) { const publishDate = $runtimeCount.getAttribute('data-publishDate') $runtimeCount.innerText = btf.diffDate(publishDate) + ' ' + GLOBAL_CONFIG.runtime } @@ -637,7 +637,7 @@ document.addEventListener('DOMContentLoaded', function () { */ const addLastPushDate = () => { const $lastPushDateItem = document.getElementById('last-push-date') - if ($lastPushDateItem !== null) { + if ($lastPushDateItem) { const lastPushDate = $lastPushDateItem.getAttribute('data-lastPushDate') $lastPushDateItem.innerText = btf.diffDate(lastPushDate, true) } @@ -685,7 +685,8 @@ document.addEventListener('DOMContentLoaded', function () { if (!$tabItem.classList.contains('active')) { const $tabContent = $tabItem.parentNode.nextElementSibling - btf.siblings($tabItem, '.active')[0].classList.remove('active') + const $siblings = btf.siblings($tabItem, '.active')[0] + $siblings && $siblings.classList.remove('active') $tabItem.classList.add('active') const tabId = $this.getAttribute('data-href').replace('#', '') const childList = [...$tabContent.children] @@ -712,7 +713,7 @@ document.addEventListener('DOMContentLoaded', function () { const toggleCardCategory = function () { const $cardCategory = document.querySelectorAll('#aside-cat-list .card-category-list-item.parent i') - if ($cardCategory.length > 0) { + if ($cardCategory.length) { $cardCategory.forEach(function (item) { item.addEventListener('click', function (e) { e.preventDefault() diff --git a/source/js/tw_cn.js b/source/js/tw_cn.js index bbde3c0..78dbd6d 100644 --- a/source/js/tw_cn.js +++ b/source/js/tw_cn.js @@ -88,8 +88,9 @@ document.addEventListener('DOMContentLoaded', function () { translateButtonObject = document.getElementById('translateLink') if (translateButtonObject) { if (currentEncoding !== targetEncoding) { - setTimeout(function () { translateBody() }, translateDelay) - if (targetEncoding === 1) { translateButtonObject.innerHTML = msgToSimplifiedChinese } else translateButtonObject.innerHTML = msgToTraditionalChinese + setTimeout(translateBody, translateDelay) + if (targetEncoding === 1) translateButtonObject.innerHTML = msgToSimplifiedChinese + else translateButtonObject.innerHTML = msgToTraditionalChinese } translateButtonObject.addEventListener('click', translatePage, false) }