commit
831dad39cf
|
@ -4,23 +4,21 @@
|
|||
<div class="card-widget card-recent-post" th:fragment="comments">
|
||||
<div class="item-headline"><i class="iconfont icon-comment-dots"></i><span>最新评论</span></div>
|
||||
<div class="aside-list" id="newcomm">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<script th:src="@{/assets/libs/twikoo/twikoo.all.min.js}"></script>
|
||||
<script th:if="${theme.config.comments.twikoo && #strings.equals(theme.config.comments.use, 'Twikoo') && not #strings.isEmpty(theme.config.comments.envId)}">
|
||||
const pagesize = [[${theme.config.sidebar.newcommentnumber}]];
|
||||
const defaultpagesize = 5;
|
||||
const finalpagesize = pagesize <= 0 ? defaultpagesize : pagesize;
|
||||
twikoo.getRecentComments({
|
||||
envId: [[${ theme.config.comments.envId }]], // 环境 ID
|
||||
// region: 'ap-guangzhou', // 环境地域,默认为 ap-shanghai,如果您的环境地域不是上海,需传此参数
|
||||
pageSize: finalpagesize, // 获取多少条,默认:10,最大:100
|
||||
includeReply: false // 是否包括最新回复,默认:false
|
||||
}).then(function (res) {
|
||||
let commenthtml = '';
|
||||
res.forEach((items)=>{
|
||||
commenthtml += `<div class="aside-list-item">
|
||||
<script th:src="@{/assets/libs/twikoo/twikoo.all.min.js}"></script>
|
||||
<script th:if="${theme.config.comments.twikoo && #strings.equals(theme.config.comments.use, 'Twikoo') && not #strings.isEmpty(theme.config.comments.envId)}">
|
||||
(()=>{
|
||||
const pagesize = [[${theme.config.sidebar.newcommentnumber}]];
|
||||
const defaultpagesize = 5;
|
||||
const finalpagesize = pagesize <= 0 ? defaultpagesize : pagesize;
|
||||
twikoo.getRecentComments({
|
||||
envId: [[${ theme.config.comments.envId }]], // 环境 ID
|
||||
// region: 'ap-guangzhou', // 环境地域,默认为 ap-shanghai,如果您的环境地域不是上海,需传此参数
|
||||
pageSize: finalpagesize, // 获取多少条,默认:10,最大:100
|
||||
includeReply: false // 是否包括最新回复,默认:false
|
||||
}).then(function (res) {
|
||||
let commenthtml = '';
|
||||
res.forEach((items)=>{
|
||||
commenthtml += `<div class="aside-list-item">
|
||||
<a class="thumbnail" href="${items.url}">
|
||||
<img loading="lazy" alt="dasda" src="${items.avatar}">
|
||||
</a>
|
||||
|
@ -34,11 +32,17 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>`
|
||||
});
|
||||
document.querySelector('#newcomm').innerHTML = commenthtml;
|
||||
}).catch(function (err) {
|
||||
// 发生错误
|
||||
console.error(err);
|
||||
});
|
||||
</script>
|
||||
});
|
||||
let necomm = document.querySelector('#newcomm')
|
||||
necomm.innerHTML = commenthtml;
|
||||
window.lazyLoadInstance && window.lazyLoadInstance.update()
|
||||
window.pjax && window.pjax.refresh(necomm)
|
||||
}).catch(function (err) {
|
||||
// 发生错误
|
||||
console.error(err);
|
||||
});
|
||||
})();
|
||||
</script>
|
||||
</div>
|
||||
</div>
|
||||
</html>
|
||||
|
|
Loading…
Reference in New Issue