breaking changes: 移除 subtitle 一句網調用(api 已失效)

feat: 右下角按鈕增加預覽進度顯示
feat: toc可設置是否顯示預覽進度
fix: 修復 TypeError: require(...) is not a function 的報錯 #1102
improvement: 日期設置相對日期時,文章的日期格式和最新評論的日期格式統一為 年月日
This commit is contained in:
Jerry
2022-11-18 18:30:25 +08:00
Unverified
parent 5c0d578e4c
commit f218a0a14a
10 changed files with 83 additions and 71 deletions

View File

@@ -88,7 +88,7 @@ const btf = {
const minuteCount = dateDiff / minute
if (monthCount > 12) {
result = datePost.toLocaleDateString().replace(/\//g, '-')
result = datePost.toISOString().slice(0,10)
} else if (monthCount >= 1) {
result = parseInt(monthCount) + ' ' + GLOBAL_CONFIG.date_suffix.month
} else if (dayCount >= 1) {
@@ -274,5 +274,16 @@ const btf = {
title: title
}, title, anchor)
}
},
getScrollPercent: (currentTop,ele) => {
const docHeight = ele.clientHeight
const winHeight = document.documentElement.clientHeight
const headerHeight = ele.offsetTop
const contentMath = (docHeight > winHeight) ? (docHeight - winHeight) : (document.documentElement.scrollHeight - winHeight)
const scrollPercent = (currentTop - headerHeight) / (contentMath)
const scrollPercentRounded = Math.round(scrollPercent * 100)
const percentage = (scrollPercentRounded > 100) ? 100 : (scrollPercentRounded <= 0) ? 0 : scrollPercentRounded
return percentage
}
}