mirror of
https://github.com/jerryc127/hexo-theme-butterfly.git
synced 2026-04-16 20:30:53 +08:00
feat: 修改 toc 打開效果
feat: 適配 hexo-blog-encrypt fix: 修復 hexo 新版本下,prismjs 的問題 improvement: 在 pjax 關閉的情況下。減少不必要的全局變量 improvement: 更新依賴版本 improvement: 頁面進入效果優化 improvement: 添加平滑滾動 improvement: 兼容性優化 improvement: 優化 lighthouse 分數 improvement: 優化代碼
This commit is contained in:
38
layout/includes/third-party/pjax.pug
vendored
38
layout/includes/third-party/pjax.pug
vendored
@@ -24,34 +24,25 @@ script.
|
||||
scrollRestoration: false
|
||||
})
|
||||
|
||||
const triggerPjaxFn = (val) => {
|
||||
if (!val) return
|
||||
Object.values(val).forEach(fn => { fn() })
|
||||
}
|
||||
|
||||
document.addEventListener('pjax:send', function () {
|
||||
|
||||
// removeEventListener
|
||||
btf.removeGlobalFnEvent('pjax')
|
||||
btf.removeGlobalFnEvent('themeChange')
|
||||
|
||||
document.getElementById('rightside').classList.remove('rightside-show')
|
||||
|
||||
if (window.aplayers) {
|
||||
for (let i = 0; i < window.aplayers.length; i++) {
|
||||
if (!window.aplayers[i].options.fixed) {
|
||||
window.aplayers[i].destroy()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
typeof typed === 'object' && typed.destroy()
|
||||
|
||||
//reset readmode
|
||||
const $bodyClassList = document.body.classList
|
||||
$bodyClassList.contains('read-mode') && $bodyClassList.remove('read-mode')
|
||||
|
||||
typeof disqusjs === 'object' && disqusjs.destroy()
|
||||
triggerPjaxFn(window.globalFn.pjaxSend)
|
||||
})
|
||||
|
||||
document.addEventListener('pjax:complete', function () {
|
||||
window.refreshFn()
|
||||
|
||||
document.addEventListener('pjax:complete', () => {
|
||||
document.querySelectorAll('script[data-pjax]').forEach(item => {
|
||||
const newScript = document.createElement('script')
|
||||
const content = item.text || item.textContent || item.innerHTML || ""
|
||||
@@ -60,20 +51,7 @@ script.
|
||||
item.parentNode.replaceChild(newScript, item)
|
||||
})
|
||||
|
||||
GLOBAL_CONFIG.islazyload && window.lazyLoadInstance.update()
|
||||
|
||||
typeof panguInit === 'function' && panguInit()
|
||||
|
||||
// google analytics
|
||||
typeof gtag === 'function' && gtag('config', '!{theme.google_analytics}', {'page_path': window.location.pathname});
|
||||
|
||||
// baidu analytics
|
||||
typeof _hmt === 'object' && _hmt.push(['_trackPageview',window.location.pathname]);
|
||||
|
||||
typeof loadMeting === 'function' && document.getElementsByClassName('aplayer').length && loadMeting()
|
||||
|
||||
// prismjs
|
||||
typeof Prism === 'object' && Prism.highlightAll()
|
||||
triggerPjaxFn(window.globalFn.pjaxComplete)
|
||||
})
|
||||
|
||||
document.addEventListener('pjax:error', e => {
|
||||
|
||||
Reference in New Issue
Block a user