From 5b925fd5d109afeae37ff0d8b17616d2630ed681 Mon Sep 17 00:00:00 2001 From: XPoet Date: Thu, 7 Jan 2021 15:23:31 +0800 Subject: [PATCH] perf: modified printThemeInfo() --- source/js/main.js | 12 ++++++++++++ source/js/utils.js | 14 -------------- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/source/js/main.js b/source/js/main.js index 9477663..778d1df 100644 --- a/source/js/main.js +++ b/source/js/main.js @@ -7,6 +7,17 @@ window.addEventListener('DOMContentLoaded', () => { repository: 'https://github.com/XPoet/hexo-theme-keep' } + // print theme base info + KEEP.printThemeInfo = () => { + const themeInfo = `${KEEP.themeInfo.name} v${KEEP.themeInfo.version}`; + console.log(`\n %c ${themeInfo} %c ${KEEP.themeInfo.repository} \n`, `color: #fadfa3; background: #333; padding: 5px 0;`, `background: #fadfa3; padding: 5px 0;`); + const footThemeInfoDom = document.querySelector('.footer .info-container .theme-info a.theme-version'); + if (footThemeInfoDom) { + footThemeInfoDom.setAttribute('href', KEEP.themeInfo.repository); + footThemeInfoDom.innerHTML = themeInfo; + } + } + KEEP.refresh = () => { KEEP.initUtils(); KEEP.initHeaderShrink(); @@ -26,5 +37,6 @@ window.addEventListener('DOMContentLoaded', () => { } } + KEEP.printThemeInfo(); KEEP.refresh(); }); diff --git a/source/js/utils.js b/source/js/utils.js index b38e7b2..6cd2fbd 100644 --- a/source/js/utils.js +++ b/source/js/utils.js @@ -15,17 +15,6 @@ KEEP.initUtils = () => { prevScrollValue: 0, defaultFontSize: 0, - // print theme base info - printThemeInfo() { - const themeInfo = `${KEEP.themeInfo.name} v${KEEP.themeInfo.version}`; - console.log(`\n %c ${themeInfo} %c ${KEEP.themeInfo.repository} \n`, `color: #fadfa3; background: #333; padding: 5px 0;`, `background: #fadfa3; padding: 5px 0;`); - const footThemeInfoDom = document.querySelector('.footer .info-container .theme-info a.theme-version'); - if (footThemeInfoDom) { - footThemeInfoDom.setAttribute('href', KEEP.themeInfo.repository); - footThemeInfoDom.innerHTML = themeInfo; - } - }, - // Scroll Style Handle styleHandleWhenScroll() { const scrollTop = document.body.scrollTop || document.documentElement.scrollTop; @@ -282,9 +271,6 @@ KEEP.initUtils = () => { } } - // print theme info - KEEP.utils.printThemeInfo(); - // init scroll KEEP.utils.registerWindowScroll();