fixed:文章id连续修复

This commit is contained in:
Vaica committed 2026-01-20 21:13:24 +08:00
1 parent 21fa47801b
commit c6adb1693f
147 files changed
+554 -260

No files matched your search

+10
View File
@@ -186,6 +186,16 @@ document.addEventListener("pjax:complete", function () {
el: '#Comments', // 绑定元素的 Selector
server: 'https://artalk.usj.cc', // 后端地址
site: '优世界', // 你的站点名
// 使用全局变量或 DOM 读取 pageKey,这里需要注意 Pjax 切换时如何获取新页面的 pid
// 由于 Pjax 只是替换 HTML,我们需要从新页面的 DOM 中提取 pid
// 建议在 single.html 中埋一个隐藏元素存储 pid,或者直接依赖 window.location (但用户想要 /post/id)
// 修正:Pjax 切换后,HTML 已经更新,如果我们在 artalk.html 中输出了正确的配置脚本,
// 那么这段 JS 代码其实是在旧页面加载的 static js 中。
// Artalk.init 在 mypjax.js 中被调用时,参数是写死的或者从当前环境获取。
// 必须动态获取当前页面的 pid。
// 方案:在 layouts/_default/single.html 中添加一个 hidden input 存储 pid
// 然后在这里读取。
pageKey: document.getElementById('data-pid')?.innerText || location.pathname,
flatMode: true,
emoticons: '/emotion/OwO.json'
})