🐛 Fixed the post expired logical over 180 days.

This commit is contained in:
elkan1788 2025-01-04 11:11:15 +08:00
parent b559782447
commit 8051ec1f09
5 changed files with 25 additions and 31 deletions

View File

@ -12,6 +12,14 @@
z-index: $zindex-5; z-index: $zindex-5;
} }
.hidden {
display: none !important;
}
.show {
display: block !important;
}
@import 'tool-buttons'; @import 'tool-buttons';
@import 'reading-progress'; @import 'reading-progress';

View File

@ -93,6 +93,7 @@
border-left: 6px solid #4A90E2; border-left: 6px solid #4A90E2;
margin: 0 0 0.85em 0; margin: 0 0 0.85em 0;
padding: 0.65em 0.15em 0.65em 0.95em; padding: 0.65em 0.15em 0.65em 0.95em;
display: none;
.post-expired-title { .post-expired-title {
color: #4A90E2; color: #4A90E2;

View File

@ -43,10 +43,6 @@
.goto-comments { .goto-comments {
display: none; display: none;
} }
.goto-comments-on {
display: block;
}
} }
@if $back2top_enable { @if $back2top_enable {

View File

@ -73,9 +73,9 @@ NexT.boot.refresh = function() {
if(NexT.CONFIG.page.comments) { if(NexT.CONFIG.page.comments) {
NexT.utils.initCommontesDispaly(); NexT.utils.initCommontesDispaly();
NexT.utils.registerCommonSwitch(); NexT.utils.registerCommonSwitch();
NexT.utils.domAddClass('#goto-comments', 'goto-comments-on'); NexT.utils.domAddClass('#goto-comments', 'show');
} else { } else {
NexT.utils.hideComments(); NexT.utils.domAddClass('#goto-comments', 'hidden');
} }
//TODO //TODO

View File

@ -14,27 +14,23 @@ NexT.utils = {
if (postLastmodTime != null) postTime = postLastmodTime.getAttribute("datetime"); if (postLastmodTime != null) postTime = postLastmodTime.getAttribute("datetime");
let expiredTip = '';
const expireCfg = NexT.CONFIG.page.expiredTips; const expireCfg = NexT.CONFIG.page.expiredTips;
let expiredTipPre = ''; let expiredTime = this.diffDate(postTime, 2);
let expiredTipSuf = '';
let expireTime = this.diffDate(postTime, 2);
if (expireTime == '0'+NexT.CONFIG.i18n.ds_days) { if (expiredTime.indexOf(NexT.CONFIG.i18n.ds_years) > -1) {
document.getElementById('post-expired-tip').style.display = 'none'; expiredTip = expireCfg.warn.split('#');
} else { } else {
if (expireTime.indexOf(NexT.CONFIG.i18n.ds_years) > -1){ let days = parseInt(expiredTime.replace(NexT.CONFIG.i18n.ds_days, '').trim(), 10);
let expireTip = expireCfg.warn.split('#'); if (days < 180) return;
expiredTipPre = expireTip[0]; expiredTip = expireCfg.info.split('#');
expiredTipSuf = expireTip[1];
} else {
let expireTip = expireCfg.info.split('#');
expiredTipPre = expireTip[0];
expiredTipSuf = expireTip[1];
} }
let expiredTip = expiredTipPre + '<span class="post-expired-times">' + expireTime + '</span>' + expiredTipSuf; let expiredTipPre = expiredTip[0];
let expiredTipSuf = expiredTip[1];
expiredTip = expiredTipPre + '<span class="post-expired-times">' + expiredTime + '</span>' + expiredTipSuf;
document.getElementById('post-expired-content').innerHTML = expiredTip; document.getElementById('post-expired-content').innerHTML = expiredTip;
} this.domAddClass('#post-expired-tip', 'show');
}, },
registerMenuClick: function () { registerMenuClick: function () {
const pMenus = document.querySelectorAll('.main-menu > li > a.menus-parent'); const pMenus = document.querySelectorAll('.main-menu > li > a.menus-parent');
@ -538,13 +534,6 @@ NexT.utils = {
}); });
}, },
hideComments: function () {
let postComments = document.querySelector('.post-comments');
if (postComments !== null) {
postComments.style.display = 'none';
}
},
hiddeLodingCmp: function (selector) { hiddeLodingCmp: function (selector) {
const loadding = document.querySelector(selector).previousElementSibling; const loadding = document.querySelector(selector).previousElementSibling;
loadding.style.display = 'none'; loadding.style.display = 'none';