perf: modified printThemeInfo()

This commit is contained in:
XPoet 2021-01-07 15:23:31 +08:00
parent 3abec3cb33
commit 5b925fd5d1
2 changed files with 12 additions and 14 deletions

View File

@ -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();
});

View File

@ -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();