fix: 修復 pjax 下, waline js 會重複加載的 bug

This commit is contained in:
Jerry
2023-01-15 01:39:16 +08:00
Unverified
parent 9a3b41912a
commit 929a5608d3
12 changed files with 59 additions and 45 deletions

View File

@@ -60,6 +60,17 @@ hexo.extend.helper.register('inject_head_js', function () {
})
`
const getCSS = `
win.getCSS = url => new Promise((resolve, reject) => {
const link = document.createElement('link')
link.rel = 'stylesheet'
link.href = url
link.onload = () => resolve()
link.onerror = () => reject()
document.head.appendChild(link)
})
`
let darkmodeJs = ''
if (darkmode.enable) {
darkmodeJs = `
@@ -144,5 +155,5 @@ hexo.extend.helper.register('inject_head_js', function () {
detectApple()
`
return `<script>(win=>{${localStore + getScript + darkmodeJs + asideStatus + detectApple}})(window)</script>`
return `<script>(win=>{${localStore + getScript + getCSS + darkmodeJs + asideStatus + detectApple}})(window)</script>`
})