fix: fixed Gitalk loading error caused by clicking too fast

This commit is contained in:
XPoet 2021-01-11 00:21:26 +08:00
parent 8f8e96be6e
commit 156920dea5
1 changed files with 15 additions and 9 deletions

View File

@ -17,6 +17,8 @@
if (__gitalk__pathnameLength > __gitalk__pathnameMaxLength) { if (__gitalk__pathnameLength > __gitalk__pathnameMaxLength) {
__gitalk__pathname = __gitalk__pathname.substring(0, __gitalk__pathnameMaxLength - 3) + '...'; __gitalk__pathname = __gitalk__pathname.substring(0, __gitalk__pathnameMaxLength - 3) + '...';
} }
try {
Gitalk && new Gitalk({ Gitalk && new Gitalk({
clientID: '<%= theme.comment.gitalk.client_id %>', clientID: '<%= theme.comment.gitalk.client_id %>',
clientSecret: '<%= theme.comment.gitalk.client_secret %>', clientSecret: '<%= theme.comment.gitalk.client_secret %>',
@ -26,6 +28,10 @@
id: __gitalk__pathname, id: __gitalk__pathname,
language: '<%= config.language %>' language: '<%= config.language %>'
}).render('gitalk-container'); }).render('gitalk-container');
} catch (e) {
window.Gitalk = null;
}
} }
if ('<%= theme.pjax.enable %>') { if ('<%= theme.pjax.enable %>') {