💄 Add post expired tip features.

This commit is contained in:
elkan1788
2025-01-03 20:48:41 +08:00
parent 9aaaf388f8
commit b559782447
14 changed files with 132 additions and 8 deletions

View File

@@ -63,9 +63,13 @@ NexT.boot.refresh = function() {
if (!NexT.CONFIG.page.isPage) return;
NexT.utils.registerSidebarTOC();
if (NexT.CONFIG.page.toc) NexT.utils.registerSidebarTOC();
if (NexT.CONFIG.page.expired) NexT.utils.calPostExpiredDate();
NexT.utils.registerCopyCode();
NexT.utils.registerImageViewer();
NexT.utils.registerPostReward();
if(NexT.CONFIG.page.comments) {
NexT.utils.initCommontesDispaly();
NexT.utils.registerCommonSwitch();
@@ -73,7 +77,6 @@ NexT.boot.refresh = function() {
} else {
NexT.utils.hideComments();
}
NexT.utils.registerImageViewer();
//TODO
/**

View File

@@ -7,6 +7,35 @@ HTMLElement.prototype.wrap = function (wrapper) {
};
NexT.utils = {
calPostExpiredDate: function() {
const postMetaDom = document.querySelector('.post-meta-container');
let postTime = postMetaDom.querySelector('time[itemprop="dateCreated datePublished"]').getAttribute("datetime");
let postLastmodTime = postMetaDom.querySelector('time[itemprop="dateModified dateLastmod"]');
if (postLastmodTime != null) postTime = postLastmodTime.getAttribute("datetime");
const expireCfg = NexT.CONFIG.page.expiredTips;
let expiredTipPre = '';
let expiredTipSuf = '';
let expireTime = this.diffDate(postTime, 2);
if (expireTime == '0'+NexT.CONFIG.i18n.ds_days) {
document.getElementById('post-expired-tip').style.display = 'none';
} else {
if (expireTime.indexOf(NexT.CONFIG.i18n.ds_years) > -1){
let expireTip = expireCfg.warn.split('#');
expiredTipPre = expireTip[0];
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;
document.getElementById('post-expired-content').innerHTML = expiredTip;
}
},
registerMenuClick: function () {
const pMenus = document.querySelectorAll('.main-menu > li > a.menus-parent');
pMenus.forEach(function (item) {