mirror of
https://github.com/jerryc127/hexo-theme-butterfly.git
synced 2026-04-10 21:17:07 +08:00
feat: 適配 hexo-blog-encrypt fix: 修復 hexo 新版本下,prismjs 的問題 improvement: 在 pjax 關閉的情況下。減少不必要的全局變量 improvement: 更新依賴版本 improvement: 頁面進入效果優化 improvement: 添加平滑滾動 improvement: 兼容性優化 improvement: 優化 lighthouse 分數 improvement: 優化代碼
46 lines
1.3 KiB
Plaintext
46 lines
1.3 KiB
Plaintext
- const { serverURL, option, pageview } = theme.waline
|
|
- const { lazyload, count, use } = theme.comments
|
|
|
|
script.
|
|
(() => {
|
|
let initFn = window.walineFn || null
|
|
|
|
const initWaline = (Fn) => {
|
|
const waline = Fn(Object.assign({
|
|
el: '#waline-wrap',
|
|
serverURL: '!{serverURL}',
|
|
pageview: !{lazyload ? false : pageview},
|
|
dark: 'html[data-theme="dark"]',
|
|
path: window.location.pathname,
|
|
comment: !{lazyload ? false : count},
|
|
}, !{JSON.stringify(option)}))
|
|
|
|
const destroyWaline = () => {
|
|
waline.destroy()
|
|
}
|
|
|
|
btf.addGlobalFn('pjax', destroyWaline, 'destroyWaline')
|
|
}
|
|
|
|
const loadWaline = () => {
|
|
if (initFn) initWaline(initFn)
|
|
else {
|
|
btf.getCSS('!{url_for(theme.asset.waline_css)}')
|
|
.then(() => import('!{url_for(theme.asset.waline_js)}'))
|
|
.then(({ init }) => {
|
|
initFn = init || Waline.init
|
|
initWaline(initFn)
|
|
window.walineFn = initFn
|
|
})
|
|
}
|
|
}
|
|
|
|
if ('!{use[0]}' === 'Waline' || !!{lazyload}) {
|
|
if (!{lazyload}) btf.loadComment(document.getElementById('waline-wrap'),loadWaline)
|
|
else setTimeout(loadWaline, 0)
|
|
} else {
|
|
window.loadOtherComment = loadWaline
|
|
}
|
|
})()
|
|
|