feat: 增加 aside 最新評論部件

style: 部分css調整和html優化
improvements: 刪除pwa中的theme-color配置,默認生成meta theme-color  close #340
improvements: 優化最後更新時間顯示(1小時內顯示 剛剛,1小時到24小時 顯示 xx小時前,1天到365天 顯示 xx天前,365天后直接顯示日期)
This commit is contained in:
Jerry
2020-08-29 01:11:11 +08:00
Unverified
parent ee6f62f4bc
commit fe97d2e63f
23 changed files with 420 additions and 86 deletions
+20 -11
View File
@@ -104,20 +104,29 @@
.aside-list
margin: 10px 0 -15px
& > span
display: block
margin-bottom: .5rem
text-align: center
& > .aside-list-item
display: flex
align-items: center
margin-bottom: 10px
padding: .3rem 0
&:first-child
padding-top: 0
&:not(:last-child)
border-bottom: 1px dashed #f5f5f5
&:last-child
margin-bottom: .3rem
// padding 8px 0
// border-bottom: 1px dashed #f5f5f5
// height: 4.72em
.thumbnail
// float: left
overflow: hidden
width: w = 4.2em
height: w
border-radius: w
& > img
width: 100%
@@ -134,19 +143,19 @@
word-break: break-all
& > .name
@extend .limit-one-line
@extend .limit-more-line
-webkit-line-clamp: 1
& > time
& > time,
& > .name
color: $theme-meta-color
font-size: 85%
& > .comment
font-size: 90%
& > .title,
& > .comment
@extend .limit-more-line
color: var(--font-color)
font-size: 95%
line-height: 1.5
-webkit-line-clamp: 2
+3
View File
@@ -123,6 +123,9 @@ if hexo-config('darkmode.enable') || hexo-config('display_mode') == 'dark'
.gist,
.aplayer
filter: brightness(.7)
#aside_content .aside-list > .aside-list-item:not(:last-child)
border-bottom: 1px dashed alpha(#FFFFFF, .1)
//
// hexo-blog-encrypt
+8 -13
View File
@@ -618,9 +618,9 @@ const addCopyright = () => {
* 網頁運行時間
*/
const addRuntime = () => {
const $runtimeCount = $('#webinfo-runtime-count')
const $runtimeCount = $('#runtimeshow')
if ($runtimeCount.length) {
const publishDate = $runtimeCount.attr('publish_date')
const publishDate = $runtimeCount.attr('data-publishDate')
$runtimeCount.text(diffDate(publishDate) + ' ' + GLOBAL_CONFIG.runtime)
}
}
@@ -629,17 +629,12 @@ const addRuntime = () => {
* 最後一次更新時間
*/
const addLastPushDate = () => {
const $lastPushDateItem = $('.webinfo-last-push-date')
const $lastPushDateItem = $('#last-push-date')
if ($lastPushDateItem.length) {
const lastPushDate = $lastPushDateItem.attr('last-push-date')
const diffDay = diffDate(lastPushDate)
if (diffDay < 1) {
$lastPushDateItem.text(GLOBAL_CONFIG.last_push_date.zeroDay)
} else if (diffDay > 365) {
$lastPushDateItem.text(lastPushDate)
} else {
$lastPushDateItem.text(diffDay + ' ' + GLOBAL_CONFIG.last_push_date.suffix)
}
const lastPushDate = $lastPushDateItem.attr('data-lastPushDate')
const diffDay = diffDate(lastPushDate, true)
console.log(diffDay)
$lastPushDateItem.text(diffDay)
}
}
@@ -810,7 +805,7 @@ const refreshFn = function () {
addLightBox()
scrollFn()
GLOBAL_CONFIG.runtime && addRuntime()
GLOBAL_CONFIG.last_push_date !== undefined && addLastPushDate()
addLastPushDate()
addTableWrap()
clickFnOfTagHide()
tabsFn.clickFnOfTabs()
+17 -3
View File
@@ -97,12 +97,26 @@ const initJustifiedGallery = function (selector) {
})
}
const diffDate = d => {
const diffDate = (d, more = false) => {
const dateNow = new Date()
const datePost = new Date(d.replace(/-/g, '/'))
const datePost = new Date(d)
const dateDiff = dateNow.getTime() - datePost.getTime()
const dayDiff = Math.floor(dateDiff / (24 * 3600 * 1000))
return dayDiff
let result
if (more) {
if (dateDiff <= 3600000) { // < 1 hour
result = GLOBAL_CONFIG.date_suffix.one_hour
} else if (dateDiff < 3600000 * 24) { // 1 hour < x < 24 hours
result = Math.floor(dateDiff / 3600000) + ' ' + GLOBAL_CONFIG.date_suffix.hours
} else if (dayDiff >= 1 || dayDiff < 365) { // 1 day < x < 365 days
result = dayDiff + ' ' + GLOBAL_CONFIG.date_suffix.day
} else { // > 365 days
result = d.toLocaleDateString().replace(/\//g, '-')
}
} else {
result = dayDiff
}
return result
}
const loadComment = (dom, callback) => {