mirror of
https://github.com/jerryc127/hexo-theme-butterfly.git
synced 2025-09-15 12:58:48 +08:00
fix: 修復 typeJSFn 重複賦值的 bug fix: 修復固定狀態欄後,標題有陰影的 bug fix: 修復 gallery 標籤將圖片鏈接截斷導致404無法加載圖片的 bug closed #1160 fix: 修復開啟導航欄固定後,點擊部分滾動向上的按鈕,滾動的目標部分被導航欄遮擋的 bug closed #1158 fix: 修復固定導航欄後,toc 被遮擋的 closed #1159 fix: 切換簡繁時,會改變 html 的 lang 屬性
92 lines
2.6 KiB
Plaintext
92 lines
2.6 KiB
Plaintext
- const { effect,source,sub,typed_option } = theme.subtitle
|
|
- let subContent = sub || new Array()
|
|
|
|
script.
|
|
window.typedJSFn = {
|
|
init: (str) => {
|
|
window.typed = new Typed('#subtitle', Object.assign({
|
|
strings: str,
|
|
startDelay: 300,
|
|
typeSpeed: 150,
|
|
loop: true,
|
|
backSpeed: 50,
|
|
}, !{JSON.stringify(typed_option)}))
|
|
},
|
|
run: (subtitleType) => {
|
|
if (!{effect}) {
|
|
if (typeof Typed === 'function') {
|
|
subtitleType()
|
|
} else {
|
|
getScript('!{url_for(theme.asset.typed)}').then(subtitleType)
|
|
}
|
|
} else {
|
|
subtitleType()
|
|
}
|
|
}
|
|
}
|
|
|
|
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)
|
|
typedJSFn.init(sub)
|
|
} else {
|
|
document.getElementById('subtitle').innerHTML = data.hitokoto
|
|
}
|
|
})
|
|
}
|
|
typedJSFn.run(subtitleType)
|
|
|
|
when 2
|
|
script.
|
|
function subtitleType () {
|
|
getScript('https://yijuzhan.com/api/word.php?m=js').then(() => {
|
|
const con = str[0]
|
|
if (!{effect}) {
|
|
const from = '出自 ' + str[1]
|
|
const sub = !{JSON.stringify(subContent)}
|
|
sub.unshift(con, from)
|
|
typedJSFn.init(sub)
|
|
} else {
|
|
document.getElementById('subtitle').innerHTML = con
|
|
}
|
|
})
|
|
}
|
|
typedJSFn.run(subtitleType)
|
|
|
|
when 3
|
|
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)
|
|
typedJSFn.init(sub)
|
|
} else {
|
|
document.getElementById('subtitle').innerHTML = result.data.content
|
|
}
|
|
})
|
|
})
|
|
}
|
|
typedJSFn.run(subtitleType)
|
|
|
|
default
|
|
- subContent = subContent.length ? subContent : new Array(config.subtitle)
|
|
script.
|
|
function subtitleType () {
|
|
if (!{effect}) {
|
|
typedJSFn.init(!{JSON.stringify(subContent)})
|
|
} else {
|
|
document.getElementById("subtitle").innerHTML = '!{subContent[0]}'
|
|
}
|
|
}
|
|
typedJSFn.run(subtitleType) |