mirror of
https://github.com/jerryc127/hexo-theme-butterfly.git
synced 2026-04-16 20:30:53 +08:00
feat: 右下角按鈕增加預覽進度顯示 feat: toc可設置是否顯示預覽進度 fix: 修復 TypeError: require(...) is not a function 的報錯 #1102 improvement: 日期設置相對日期時,文章的日期格式和最新評論的日期格式統一為 年月日
97 lines
2.8 KiB
Plaintext
97 lines
2.8 KiB
Plaintext
- const { effect,loop,source,sub,startDelay,typeSpeed,backSpeed } = theme.subtitle
|
|
- let subContent = sub || new Array()
|
|
|
|
case source
|
|
when 1
|
|
script.
|
|
function subtitleType () {
|
|
fetch('https://v1.hitokoto.cn')
|
|
.then(response => response.json())
|
|
.then(data => {
|
|
if (!{effect}) {
|
|
const from = '出自 ' + data.from
|
|
const sub = !{JSON.stringify(subContent)}
|
|
sub.unshift(data.hitokoto, from)
|
|
window.typed = new Typed('#subtitle', {
|
|
strings: sub,
|
|
startDelay: !{startDelay},
|
|
typeSpeed: !{typeSpeed},
|
|
loop: !{loop},
|
|
backSpeed: !{backSpeed},
|
|
})
|
|
} else {
|
|
document.getElementById('subtitle').innerHTML = data.hitokoto
|
|
}
|
|
})
|
|
}
|
|
|
|
if (!{effect}) {
|
|
if (typeof Typed === 'function') {
|
|
subtitleType()
|
|
} else {
|
|
getScript('!{url_for(theme.asset.typed)}').then(subtitleType)
|
|
}
|
|
} else {
|
|
subtitleType()
|
|
}
|
|
|
|
when 2
|
|
script.
|
|
function subtitleType () {
|
|
getScript('https://sdk.jinrishici.com/v2/browser/jinrishici.js').then(() => {
|
|
jinrishici.load(result =>{
|
|
if (!{effect}) {
|
|
const sub = !{JSON.stringify(subContent)}
|
|
const content = result.data.content
|
|
sub.unshift(content)
|
|
window.typed = new Typed('#subtitle', {
|
|
strings: sub,
|
|
startDelay: !{startDelay},
|
|
typeSpeed: !{typeSpeed},
|
|
loop: !{loop},
|
|
backSpeed: !{backSpeed},
|
|
})
|
|
} else {
|
|
document.getElementById('subtitle').innerHTML = result.data.content
|
|
}
|
|
})
|
|
})
|
|
}
|
|
|
|
if (!{effect}) {
|
|
if (typeof Typed === 'function') {
|
|
subtitleType()
|
|
} else {
|
|
getScript('!{url_for(theme.asset.typed)}').then(subtitleType)
|
|
}
|
|
} else {
|
|
subtitleType()
|
|
}
|
|
|
|
default
|
|
- subContent = subContent.length ? subContent : new Array(config.subtitle)
|
|
script.
|
|
function subtitleType () {
|
|
if (!{effect}) {
|
|
window.typed = new Typed("#subtitle", {
|
|
strings: !{JSON.stringify(subContent)},
|
|
startDelay: !{startDelay},
|
|
typeSpeed: !{typeSpeed},
|
|
loop: !{loop},
|
|
backSpeed: !{backSpeed}
|
|
})
|
|
} else {
|
|
document.getElementById("subtitle").innerHTML = '!{subContent[0]}'
|
|
}
|
|
}
|
|
|
|
if (!{effect}) {
|
|
if (typeof Typed === 'function') {
|
|
subtitleType()
|
|
} else {
|
|
getScript('!{url_for(theme.asset.typed)}').then(subtitleType)
|
|
}
|
|
} else {
|
|
subtitleType()
|
|
}
|