Merge pull request #616 from HenryZeng-Zero/main

增加对Artalk旧版本的支持
This commit is contained in:
困困鱼 2024-01-10 17:39:56 +08:00 committed by GitHub
commit 373bcafbb5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 25 additions and 3 deletions

View File

@ -11,13 +11,35 @@
countEl: '#ArtalkCount' countEl: '#ArtalkCount'
}, null)) }, null))
if (GLOBAL_CONFIG.lightbox === 'null') return function versionOld(ctx){
window.artalkItem.on('list-loaded', () => { // 旧版本兼容性补丁
window.artalkItem.ctx.get('list').getCommentNodes().forEach(comment => { ctx.getCommentList().forEach(comment => {
const $content = comment.getRender().$content
btf.loadLightbox($content.querySelectorAll('img:not([atk-emoticon])'))
})
}
function version_2_7_3_WithUpper(ctx){
// 2.7.3 版本及以后版本支持
ctx.get('list').getCommentNodes().forEach(comment => {
const $content = comment .getRender().$content const $content = comment .getRender().$content
btf.loadLightbox($content.querySelectorAll('img:not([atk-emoticon])')) btf.loadLightbox($content.querySelectorAll('img:not([atk-emoticon])'))
}) })
}
function versionCheck(ctx){
if(ctx.getCommentList != undefined){
// Artalk 版本小于于 2.7.3
versionOld(ctx);
}else{
version_2_7_3_WithUpper(ctx);
}
}
if (GLOBAL_CONFIG.lightbox === 'null') return
window.artalkItem.on('list-loaded', () => {
versionCheck(window.artalkItem.ctx);
}) })
} }