添加第三方chat服務 crisp

This commit is contained in:
Jerry
2020-07-22 13:56:54 +08:00
Unverified
parent 5ee7976c4a
commit 1a2568d645
12 changed files with 166 additions and 130 deletions

View File

@@ -196,7 +196,6 @@ const sidebarFn = () => {
/**
* 首頁top_img底下的箭頭
*/
const indexScrollDown = () => {
$('#scroll_down').on('click', function () {
scrollToDest('#content-inner')
@@ -423,16 +422,6 @@ const scrollFn = function () {
}
}
/**
* 點擊滾回頂部
*/
const backToTop = function () {
$('#go-up').on('click', function () {
scrollToDest('body')
})
}
/**
* toc
*/
@@ -542,34 +531,61 @@ const tocFn = function () {
}
/**
* 閲讀模式
*/
const readModeToggle = function () {
$('#readmode').on('click', function () {
$('body').toggleClass('read-mode')
})
}
/**
* 字體調整
* Rightside
*/
let $rightsideEle = $('#rightside')
// read-mode
$rightsideEle.on('click', '#readmode', function () {
$('body').toggleClass('read-mode')
})
// font change
const originFontSize = $('body').css('font-size')
const fontChange = function () {
$('#font_plus').click(function () {
const nowFontSize = parseFloat($('body').css('font-size'))
if (nowFontSize < 20) {
$('body').css('font-size', nowFontSize + 1)
}
})
$('#font_minus').click(function () {
const nowFontSize = parseFloat($('body').css('font-size'))
if (nowFontSize > 10) {
$('body').css('font-size', nowFontSize - 1)
$rightsideEle.on('click', '#font_plus', () => {
const nowFontSize = parseFloat($('body').css('font-size'))
if (nowFontSize < 20) {
$('body').css('font-size', nowFontSize + 1)
}
})
$rightsideEle.on('click', '#font_minus', () => {
const nowFontSize = parseFloat($('body').css('font-size'))
if (nowFontSize > 10) {
$('body').css('font-size', nowFontSize - 1)
}
})
// Switch Between Light And Dark Mode
if ($('#darkmode').length) {
const switchReadMode = function () {
const nowMode = document.documentElement.getAttribute('data-theme') === 'dark' ? 'dark' : 'light'
if (nowMode === 'light') {
activateDarkMode()
Cookies.set('theme', 'dark', 2)
GLOBAL_CONFIG.Snackbar !== undefined && snackbarShow(GLOBAL_CONFIG.Snackbar.day_to_night)
} else {
activateLightMode()
Cookies.set('theme', 'light', 2)
GLOBAL_CONFIG.Snackbar !== undefined && snackbarShow(GLOBAL_CONFIG.Snackbar.night_to_day)
}
}
$rightsideEle.on('click', '#darkmode', () => {
switchReadMode()
typeof utterancesTheme === 'function' && utterancesTheme()
typeof FB === 'object' && window.loadFBComment()
window.DISQUS && $('#disqus_thread').children().length && setTimeout(() => window.disqusReset(), 200)
})
}
// rightside 點擊設置 按鈕 展開
$rightsideEle.on('click', '#rightside_config', () => $('#rightside-config-hide').toggleClass('show'))
// Back to top
$rightsideEle.on('click', '#go-up', () => scrollToDest('body'))
/**
* menu
* 側邊欄sub-menu 展開/收縮
@@ -589,15 +605,6 @@ const subMenuFn = function () {
})
}
/**
* rightside 點擊設置 按鈕 展開
*/
const rightsideConfigClick = function () {
$('#rightside_config').on('click', function () {
$('#rightside-config-hide').toggleClass('show')
})
}
/**
* 複製時加上版權信息
*/
@@ -624,34 +631,6 @@ const addCopyright = function () {
}
}
/**
* Darkmode
*/
const switchDarkmode = function () {
const $darkModeButton = $('#darkmode')
if ($darkModeButton.length) {
const switchReadMode = function () {
const nowMode = document.documentElement.getAttribute('data-theme') === 'dark' ? 'dark' : 'light'
if (nowMode === 'light') {
activateDarkMode()
Cookies.set('theme', 'dark', 2)
GLOBAL_CONFIG.Snackbar !== undefined && snackbarShow(GLOBAL_CONFIG.Snackbar.day_to_night)
} else {
activateLightMode()
Cookies.set('theme', 'light', 2)
GLOBAL_CONFIG.Snackbar !== undefined && snackbarShow(GLOBAL_CONFIG.Snackbar.night_to_day)
}
}
$darkModeButton.click(function () {
switchReadMode()
typeof utterancesTheme === 'function' && utterancesTheme()
typeof FB === 'object' && window.loadFBComment()
window.DISQUS && $('#disqus_thread').children().length && setTimeout(() => window.disqusReset(), 200)
})
}
}
/**
* 網頁運行時間
*/
@@ -813,8 +792,6 @@ const refreshFn = function () {
sidebarAutoOpen()
toggleSidebarFn()
GLOBAL_CONFIG_SITE.isSidebar && tocFn()
fontChange()
readModeToggle()
GLOBAL_CONFIG.noticeOutdate !== undefined && postNoticeUpdate()
}
@@ -825,9 +802,6 @@ const refreshFn = function () {
justifiedGalleryRun()
lightBox()
scrollFn()
backToTop()
rightsideConfigClick()
switchDarkmode()
GLOBAL_CONFIG.runtime && runtimeShow()
addTableWrap()
tagHideClick()

View File

@@ -1,7 +1,6 @@
(function () {
const translate = GLOBAL_CONFIG.translate
const snackbarData = GLOBAL_CONFIG.Snackbar
const defaultEncoding = translate.defaultEncoding // 網站默認語言1: 繁體中文, 2: 簡體中文
const translateDelay = translate.translateDelay // 延遲時間,若不在前, 要設定延遲翻譯時間, 如100表示100ms,默認為0
const msgToTraditionalChinese = translate.msgToTraditionalChinese // 此處可以更改為你想要顯示的文字