修复最近评论遍历数量

This commit is contained in:
stonewu 2023-08-10 17:11:34 +08:00
parent e4f75a00db
commit ec253ed2f3
3 changed files with 16 additions and 16 deletions

View File

@ -3,7 +3,7 @@ var btf = {
// 修改时间显示"最近"
diffDate: function (d, more = false) {
diffDateExact: function (d, more = false) {
const dateNow = new Date();
const datePost = new Date(d);
const dateDiff = dateNow.getTime() - datePost.getTime();
@ -265,11 +265,11 @@ var btf = {
} else if (dayCount >= 1) {
result = parseInt(dayCount) + '' + GLOBAL_CONFIG.date_suffix.day
} else if (hourCount >= 1) {
result = '最近'
// result = parseInt(hourCount) + ' ' + GLOBAL_CONFIG.date_suffix.hour
// result = '最近'
result = parseInt(hourCount) + ' ' + GLOBAL_CONFIG.date_suffix.hour
} else if (minuteCount >= 1) {
result = '最近'
// result = parseInt(minuteCount) + ' ' + GLOBAL_CONFIG.date_suffix.min
// result = '最近'
result = parseInt(minuteCount) + ' ' + GLOBAL_CONFIG.date_suffix.min
} else {
result = GLOBAL_CONFIG.date_suffix.just
}

View File

@ -5,7 +5,7 @@
<div class="item-headline"><i class="iconfont icon-comment-dots"></i><span>最新评论</span></div>
<div class="aside-list" id="newcomm">
<th:block th:if="${#strings.equals(theme.config.comments.use, 'commentWidget') }">
<div class="aside-list-item" th:each="comment : ${commentFinder.list(null, 1, 10)}" th:with="post = ${postFinder.getByName(comment.spec.subjectRef.name)}" >
<div class="aside-list-item" th:each="comment,iterStat : ${commentFinder.list(null, 1, 10)}" th:with="post = ${postFinder.getByName(comment.spec.subjectRef.name)}" th:if="${iterStat.index < 5}">
<a class="thumbnail" th:href="${post.status.permalink + '#comment-' + comment.metadata.name}" data-pjax-state="">
<img loading="lazy" alt="头像" th:src="${#strings.isEmpty(comment.owner.avatar)?'https://cravatar.cn/avatar/?d=mp':comment.owner.avatar}" data-ll-status="loading" class="entered loading">
</a>
@ -20,15 +20,6 @@
</div>
</div>
</div>
<script data-pjax>
window.addEventListener('load', () => {
$(".aside-list time").each(function () {
var timeVal = $(this).attr("datetime");
$(this).text(btf.diffDate(timeVal,true));
console.log(1);
})
});
</script>
</th:block>
<script th:if="${theme.config.comments.twikooEnable && #strings.equals(theme.config.comments.use, 'Twikoo') && not #strings.isEmpty(theme.config.comments.twikoos.envId)}">

View File

@ -16,7 +16,7 @@
</div>
<div class="aside-list">
<th:block th:if="${#strings.equals(theme.config.comments.use, 'commentWidget') }">
<div class="aside-list-item" th:each="comment : ${commentFinder.list(null, 1, 10)}" th:with="post = ${postFinder.getByName(comment.spec.subjectRef.name)}">
<div class="aside-list-item" th:each="comment,iterStat : ${commentFinder.list(null, 1, 10)}" th:with="post = ${postFinder.getByName(comment.spec.subjectRef.name)}" th:if="${iterStat.index < 4}">
<a th:href="${post.status.permalink + '#comment-' + comment.metadata.name}" class="thumbnail" data-pjax-state="">
<img th:src="${#strings.isEmpty(comment.owner.avatar)?'https://cravatar.cn/avatar/?d=mp':comment.owner.avatar}"
th:alt="${comment.owner.displayName}" data-ll-status="loaded" class="entered loaded">
@ -27,6 +27,15 @@
<time th:datetime="${#dates.format(comment.metadata.creationTimestamp, 'yyyy-MM-dd HH:mm:ss')}"></time>
</div>
</div>
<script data-pjax>
window.addEventListener('load', () => {
$(".aside-list time").each(function () {
var timeVal = $(this).attr("datetime");
$(this).text(btf.diffDateExact(timeVal,true));
console.log(1);
})
});
</script>
</th:block>
<span th:if="${#strings.equals(theme.config.comments.use, 'Twikoo') }">正在加载中...</span></div>
</div>