mirror of
https://github.com/jerryc127/hexo-theme-butterfly.git
synced 2025-09-15 12:58:48 +08:00
Merge pull request #897 from kkfive/patch-1
perf: 优化twikoo评论,无评论数容器时不调用API获取
This commit is contained in:
commit
b1e40b33d7
@ -15,13 +15,15 @@ script.
|
|||||||
}
|
}
|
||||||
|
|
||||||
const getCount = () => {
|
const getCount = () => {
|
||||||
|
const countELement = document.getElementById('twikoo-count')
|
||||||
|
if(!countELement) return
|
||||||
twikoo.getCommentsCount({
|
twikoo.getCommentsCount({
|
||||||
envId: '!{envId}',
|
envId: '!{envId}',
|
||||||
region: '!{region}',
|
region: '!{region}',
|
||||||
urls: [window.location.pathname],
|
urls: [window.location.pathname],
|
||||||
includeReply: false
|
includeReply: false
|
||||||
}).then(function (res) {
|
}).then(function (res) {
|
||||||
document.getElementById('twikoo-count').innerText = res[0].count
|
countELement.innerText = res[0].count
|
||||||
}).catch(function (err) {
|
}).catch(function (err) {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
});
|
});
|
||||||
@ -48,4 +50,4 @@ script.
|
|||||||
loadTwikoo()
|
loadTwikoo()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})()
|
})()
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user