-
-
Notifications
You must be signed in to change notification settings - Fork 371
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
怎么让评论区的验证码插件在启用pjax时保证加载 #1044
Comments
@Deepsea-CN,感谢你给 sakurairo 提出了 issue。ヾ(≧▽≦*)o |
任何人都可以处理此问题。 |
主题这里的pjax回调机制似乎没有写好,我看了 cloudfare turnstile docs 相关文档 cloudafare 推荐使用的 js 外链是 window.onloadTurnstileCallback = function () {
turnstile.render("#example-container", {
sitekey: "<YOUR_SITE_KEY>",
callback: function (token) {
console.log(`Challenge Success ${token}`);
},
});
}; 但很不幸的是,主题相关的pjax回调方法不能识别 不过您也可以这样做绕过该限制: <script>
function initTurnstile() {
turnstile.render("#example-container", {
sitekey: "<YOUR_SITE_KEY>",
callback: function (token) {
console.log(`Challenge Success ${token}`);
},
});
}
document.addEventListener('DOMContentLoaded', function() {
loadTurnstile();
});
function loadTurnstile() {
const oldScript = document.querySelector('script[src*="turnstile/v0/api.js"]');
if (oldScript) {
oldScript.remove();
}
const script = document.createElement('script');
script.src = "https://challenges.cloudflare.com/turnstile/v0/api.js";
script.async = true;
script.onload = function() {
initTurnstile();
};
document.body.appendChild(script);
}
</script> 另外在主题根目录的 header.php 115行左右手动添加以下回调方法: if (typeof turnstile !== 'undefined') {
turnstile.remove('#example-container');
}
loadTurnstile(); |
我认为是时候完善主题的PJAX回调了( |
速速加入维护团队
Outlook for iOS<https://aka.ms/o0ukef> を入手
…________________________________
差出人: Sualiu ***@***.***>
送信日�r: Thursday, January 9, 2025 5:44:57 PM
宛先: mirai-mamori/Sakurairo ***@***.***>
CC: Subscribed ***@***.***>
件名: Re: [mirai-mamori/Sakurairo] 怎么让评论区的验证码插件在启用pjax时保证加载 (Issue #1044)
我认为是时候修改完善主题的PJAX回调了(
―
Reply to this email directly, view it on GitHub<#1044 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AOUJUFSODANOKTWCMRBN72L2JYZITAVCNFSM6AAAAABU3MNOFCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDKNZZGQ2TSNJQGQ>.
You are receiving this because you are subscribed to this thread.Message ID: ***@***.***>
|
大致范围:
pjax加载
具体行为描述:
,评论区不能加载出来验证码必须刷新
尝试:
尝试把cf turnstile的js地址添加进pjax后仍需加载的资源里,页面的验证码框体依然不能出现,看源代码那一部分没有正常加载
配置与环境:
略
截图(若有)
补充信息:
The text was updated successfully, but these errors were encountered: