💄 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

@@ -12,7 +12,7 @@
@include alert-styles(#{$key}, $color);
}
.post-alert-title {
.post-alert-title, .post-expired-title {
display: flex;
align-items: center;
@@ -31,6 +31,6 @@
}
}
.post-alert-content {
.post-alert-content, .post-expired-content {
color: var(--text-color);
}

View File

@@ -86,5 +86,26 @@
visibility: hidden;
}
@import 'post-alert';
.post-expired-tip {
font-size: 0.825em;
border: 1px solid #4A90E2;
border-left: 6px solid #4A90E2;
margin: 0 0 0.85em 0;
padding: 0.65em 0.15em 0.65em 0.95em;
.post-expired-title {
color: #4A90E2;
font-weight: bold;
}
.post-expired-times {
font-weight: bold;
font-size: 1.15em;
color: #e5534b;
margin: 0 3px;
}
}
@import 'post-alert';
}

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) {