Merge pull request #897 from kkfive/patch-1

perf: 优化twikoo评论,无评论数容器时不调用API获取
This commit is contained in:
Jerry Wong 2022-05-16 01:49:53 +08:00 committed by GitHub
commit b1e40b33d7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -15,13 +15,15 @@ script.
}
const getCount = () => {
const countELement = document.getElementById('twikoo-count')
if(!countELement) return
twikoo.getCommentsCount({
envId: '!{envId}',
region: '!{region}',
urls: [window.location.pathname],
includeReply: false
}).then(function (res) {
document.getElementById('twikoo-count').innerText = res[0].count
countELement.innerText = res[0].count
}).catch(function (err) {
console.error(err);
});