🐛 適配hexo 5.0.0 修復toc點擊不會跳轉的bugs

🐛 適配hexo 5.0.0 修復toc點擊不會跳轉的bugs
🍻 文件整理
🍻 UI微調
This commit is contained in:
Jerry
2020-08-01 01:50:01 +08:00
Unverified
parent ddb728d8f4
commit 507453671a
56 changed files with 385 additions and 204 deletions

View File

@@ -182,7 +182,7 @@ const sidebarFn = () => {
closeMobileSidebar('toc')
} else {
e.preventDefault()
scrollToDest($(this).attr('href'))
scrollToDest(decodeURI($(this).attr('href')))
}
})
}
@@ -464,7 +464,7 @@ const tocFn = function () {
// find head position & add active class
// DOM Hierarchy:
// ol.toc > (li.toc-item, ...)
// li.toc-item > (a.toc-link, ol.toc-child > (li.toc-item, ...))
// li.toc-item > (a.toc-link, ol.toc-2child > (li.toc-item, ...))
const findHeadPosition = function (top) {
// assume that we are not in the post page if no TOC link be found,
// thus no need to update the status
@@ -477,7 +477,7 @@ const tocFn = function () {
list.each(function () {
const head = $(this)
if (top > head.offset().top - 25) {
currentId = '#' + $(this).attr('id')
currentId = '#' + encodeURI($(this).attr('id'))
}
})
@@ -602,10 +602,10 @@ const clickFnOfSubMenu = function () {
/**
* 複製時加上版權信息
*/
const addCopyright = function () {
const addCopyright = () => {
const copyright = GLOBAL_CONFIG.copyright
document.body.oncopy = function (event) {
event.preventDefault()
document.body.oncopy = (e) => {
e.preventDefault()
let textFont; const copyFont = window.getSelection(0).toString()
if (copyFont.length > copyright.limitCount) {
textFont = copyFont + '\n' + '\n' + '\n' +
@@ -616,10 +616,9 @@ const addCopyright = function () {
} else {
textFont = copyFont
}
if (event.clipboardData) {
return event.clipboardData.setData('text', textFont)
if (e.clipboardData) {
return e.clipboardData.setData('text', textFont)
} else {
// 兼容IE
return window.clipboardData.setData('text', textFont)
}
}
@@ -628,7 +627,7 @@ const addCopyright = function () {
/**
* 網頁運行時間
*/
const addRuntime = function () {
const addRuntime = () => {
const $runtimeCount = $('#webinfo-runtime-count')
if ($runtimeCount.length) {
const publishDate = $runtimeCount.attr('publish_date')
@@ -649,7 +648,6 @@ const addTableWrap = function () {
/**
* 百度推送
*/
const pushToBaidu = () => {
const bp = document.createElement('script')
const curProtocol = window.location.protocol.split(':')[0]
@@ -666,7 +664,6 @@ const pushToBaidu = () => {
/**
* tag-hide
*/
const clickFnOfTagHide = function () {
const $hideInline = $('.hide-button')
if ($hideInline.length) {