- let option = theme.twikoo.option ? JSON.stringify(theme.twikoo.option) : false script. (()=>{ const $countDom = document.getElementById('twikoo-count') const init = () => { let initData = { envId: '!{theme.twikoo.envId}', el: '#twikoo-wrap' } if (!{Boolean(option)}) { const otherData = !{option} initData = Object.assign(initData, otherData) } twikoo.init(initData) } const getCount = () => { twikoo.getCommentsCount({ envId: '!{theme.twikoo.envId}', urls: [window.location.pathname], includeReply: false }).then(function (res) { $countDom.innerText = res[0].count }).catch(function (err) { console.error(err); }); } const loadTwikoo = (bool = false) => { if (typeof twikoo === 'object') { init() bool && $countDom && setTimeout(getCount,0) } else { getScript('!{theme.CDN.twikoo}').then(()=> { init() bool && $countDom && setTimeout(getCount,0) }) } } if ('!{theme.comments.use[0]}' === 'Twikoo' || !!{theme.comments.lazyload}) { if (!{theme.comments.lazyload}) btf.loadComment(document.getElementById('twikoo-wrap'), loadTwikoo) else loadTwikoo(true) } else { window.loadOtherComment = () => { loadTwikoo() } } })()