🐛 fix: 修復highlight_shrink設為false時,導致script報錯的bug

🐛 fix: 修復highlight_shrink設為true時,按鈕點擊無反應,沒有打開代碼框的bug
🐛 fix: 修復自動切換darkmode時,切換按鈕icon沒有變更的bug
This commit is contained in:
Jerry
2020-03-24 19:03:51 +08:00
parent ce72ba4f5d
commit c134d4fc86
2 changed files with 5 additions and 6 deletions

View File

@@ -112,7 +112,7 @@ script.
baiduPush: !{baiduPush},
highlightCopy: !{highlightCopy},
highlightLang: !{highlightLang},
highlightShrink: !{highlightShrink},
highlightShrink: '!{highlightShrink}',
isFontAwesomeV5: !{isFontAwesomeV5}
}

View File

@@ -271,16 +271,16 @@ $(function () {
* 代碼收縮
*/
const $highlightTools = $('.highlight-tools')
if (isHighlightShrink === true) {
if (isHighlightShrink === 'true') {
$highlightTools.append('<i class="fa fa-angle-down code-expand code-closed" aria-hidden="true"></i>')
} else if (isHighlightShrink === false) {
} else if (isHighlightShrink === 'false') {
$highlightTools.append('<i class="fa fa-angle-down code-expand" aria-hidden="true"></i>')
}
$(document).on('click', '.highlight-tools >.code-expand', function () {
var $table = $(this).parent().next()
if ($(this).hasClass('code-closed')) {
$table.css('display', '')
$table.css('display', 'block')
$(this).removeClass('code-closed')
} else {
$table.css('display', 'none')
@@ -668,8 +668,7 @@ $(function () {
var isFontAwesomeV5 = GLOBAL_CONFIG.isFontAwesomeV5
var $darkModeButtom = $('#darkmode')
if (typeof autoChangeMode !== 'undefined') {
if (Cookies.get('theme') === 'dark') changeLightIcon()
else changeDarkIcon()
document.documentElement.getAttribute('data-theme') === 'dark' ? changeLightIcon() : changeDarkIcon()
}
function changeLightIcon () {