修bug
This commit is contained in:
1 parent
dbc07992e7
commit
b537dd0f7f
2 files changed
+29
-4
No files matched your search
@@ -13,7 +13,23 @@ const config = {
|
|||||||
---
|
---
|
||||||
|
|
||||||
<div id="tcomment"></div>
|
<div id="tcomment"></div>
|
||||||
<script is:inline src="https://cdn.staticfile.org/twikoo/1.6.44/twikoo.all.min.js"></script>
|
<script define:vars={{ config }}>
|
||||||
<script is:inline define:vars={{ config }}>
|
function loadTwikoo() {
|
||||||
twikoo.init(config)
|
|
||||||
|
// 动态加载 Twikoo 脚本,并在加载完成后执行 twikoo.init
|
||||||
|
|
||||||
|
const script = document.createElement('script');
|
||||||
|
script.src = 'https://cdn.jsdelivr.net/npm/twikoo@1.6.44/dist/twikoo.min.js';
|
||||||
|
script.defer = true;
|
||||||
|
script.onload = () => {
|
||||||
|
if (window.twikoo) {
|
||||||
|
window.twikoo.init(config);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
// script.onerror = () => {
|
||||||
|
// console.error('Twikoo script load failed');
|
||||||
|
// };
|
||||||
|
document.body.appendChild(script);
|
||||||
|
}
|
||||||
|
document.addEventListener("loadComment", loadTwikoo, { once: true }); // 监听加载评论事件,但是我们只能监听一次,从而避免多次触发。
|
||||||
</script>
|
</script>
|
||||||
@@ -378,6 +378,7 @@ function init() {
|
|||||||
loadHue();
|
loadHue();
|
||||||
initCustomScrollbar();
|
initCustomScrollbar();
|
||||||
showBanner();
|
showBanner();
|
||||||
|
initCommentComponent(); // 调用initCommentComponent()函数,twikoo
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Load settings when entering the site */
|
/* Load settings when entering the site */
|
||||||
@@ -413,7 +414,15 @@ const setup = () => {
|
|||||||
navbar.classList.add('navbar-hidden')
|
navbar.classList.add('navbar-hidden')
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
window.swup.hooks.on('content:replace', initCustomScrollbar)
|
// window.swup.hooks.on('content:replace', initCustomScrollbar)
|
||||||
|
|
||||||
|
window.swup.hooks.on("content:replace", () => {
|
||||||
|
|
||||||
|
initCustomScrollbar();
|
||||||
|
|
||||||
|
initCommentComponent(); // 添加代码调用
|
||||||
|
|
||||||
|
});
|
||||||
window.swup.hooks.on('visit:start', (visit: {to: {url: string}}) => {
|
window.swup.hooks.on('visit:start', (visit: {to: {url: string}}) => {
|
||||||
// change banner height immediately when a link is clicked
|
// change banner height immediately when a link is clicked
|
||||||
const bodyElement = document.querySelector('body')
|
const bodyElement = document.querySelector('body')
|
||||||
|
|||||||
Reference in new issue
Block a user