diff --git a/src/components/comment/Twikoo.astro b/src/components/comment/Twikoo.astro index 83ec339..7b200ab 100644 --- a/src/components/comment/Twikoo.astro +++ b/src/components/comment/Twikoo.astro @@ -14,11 +14,31 @@ const config = {
diff --git a/src/pages/posts/[...slug].astro b/src/pages/posts/[...slug].astro index cdec702..318892c 100644 --- a/src/pages/posts/[...slug].astro +++ b/src/pages/posts/[...slug].astro @@ -148,8 +148,10 @@ const jsonLd = { window.tianliGPT_Title = '智能摘要'; window.tianliGPT_key = 'S-HMJ7UXQGBIAZ0U8Q'; - // 立即尝试初始化 - function tryInitTianliGPT() { + // Expose on window so the loader script's onload handler (in a different + // inline script block) can always reach the latest version of this function + // after Swup page transitions replace the DOM content. + window._tryInitTianliGPT = function tryInitTianliGPT() { if (typeof window.tianliGPT === 'object' && typeof window.tianliGPT.checkURLAndRun === 'function') { @@ -166,33 +168,52 @@ const jsonLd = { }, 500); } else if (window.tianliGPT_scriptLoaded) { // 脚本已请求加载但尚未就绪,继续等待 - setTimeout(tryInitTianliGPT, 200); + setTimeout(window._tryInitTianliGPT, 200); } // else: 脚本未加载(无功能性同意),停止轮询 - } + }; // 开始尝试 - tryInitTianliGPT(); + window._tryInitTianliGPT();