mirror of
https://github.com/jerryc127/hexo-theme-butterfly.git
synced 2026-04-12 22:17:06 +08:00
🎨 代碼優化
This commit is contained in:
@@ -12,6 +12,12 @@ div
|
|||||||
if theme.fancybox
|
if theme.fancybox
|
||||||
script(src=url_for(theme.CDN.fancybox))
|
script(src=url_for(theme.CDN.fancybox))
|
||||||
|
|
||||||
|
if theme.instantpage
|
||||||
|
script(src=url_for(theme.CDN.instantpage) type="module" defer)
|
||||||
|
|
||||||
|
if theme.lazyload.enable
|
||||||
|
script(src=url_for(theme.CDN.lazyload) async)
|
||||||
|
|
||||||
if theme.fireworks && theme.fireworks.enable
|
if theme.fireworks && theme.fireworks.enable
|
||||||
script(src=url_for(theme.CDN.anime))
|
script(src=url_for(theme.CDN.anime))
|
||||||
script(src=url_for(theme.CDN.fireworks))
|
script(src=url_for(theme.CDN.fireworks))
|
||||||
@@ -19,6 +25,9 @@ div
|
|||||||
if (theme.snackbar && theme.snackbar.enable)
|
if (theme.snackbar && theme.snackbar.enable)
|
||||||
script(src=url_for(theme.CDN.snackbar))
|
script(src=url_for(theme.CDN.snackbar))
|
||||||
|
|
||||||
|
if theme.pangu && theme.pangu.enable
|
||||||
|
include ./third-party/pangu.pug
|
||||||
|
|
||||||
if (theme.canvas_ribbon && theme.canvas_ribbon.enable)
|
if (theme.canvas_ribbon && theme.canvas_ribbon.enable)
|
||||||
include ./third-party/canvas-ribbon.pug
|
include ./third-party/canvas-ribbon.pug
|
||||||
|
|
||||||
@@ -35,12 +44,6 @@ div
|
|||||||
POWERMODE.shake = #{theme.activate_power_mode.shake};
|
POWERMODE.shake = #{theme.activate_power_mode.shake};
|
||||||
document.body.addEventListener('input', POWERMODE);
|
document.body.addEventListener('input', POWERMODE);
|
||||||
|
|
||||||
if theme.instantpage
|
|
||||||
script(src=url_for(theme.CDN.instantpage) type="module" defer)
|
|
||||||
|
|
||||||
if theme.lazyload.enable
|
|
||||||
script(src=url_for(theme.CDN.lazyload) async)
|
|
||||||
|
|
||||||
//- 鼠標特效
|
//- 鼠標特效
|
||||||
if theme.click_heart
|
if theme.click_heart
|
||||||
script(src=url_for(theme.CDN.click_heart) async)
|
script(src=url_for(theme.CDN.click_heart) async)
|
||||||
@@ -48,9 +51,6 @@ div
|
|||||||
if theme.ClickShowText && theme.ClickShowText.enable
|
if theme.ClickShowText && theme.ClickShowText.enable
|
||||||
script(src=url_for(theme.CDN.ClickShowText) async)
|
script(src=url_for(theme.CDN.ClickShowText) async)
|
||||||
|
|
||||||
if theme.pangu && theme.pangu.enable
|
|
||||||
include ./third-party/pangu.pug
|
|
||||||
|
|
||||||
//- search
|
//- search
|
||||||
if theme.algolia_search && theme.algolia_search.enable
|
if theme.algolia_search && theme.algolia_search.enable
|
||||||
script(src=url_for(theme.CDN.algolia_js))
|
script(src=url_for(theme.CDN.algolia_js))
|
||||||
@@ -76,15 +76,15 @@ div
|
|||||||
if theme.busuanzi.site_uv || theme.busuanzi.site_pv || theme.busuanzi.page_pv
|
if theme.busuanzi.site_uv || theme.busuanzi.site_pv || theme.busuanzi.page_pv
|
||||||
script(async src=url_for(theme.CDN.busuanzi))
|
script(async src=url_for(theme.CDN.busuanzi))
|
||||||
|
|
||||||
|
!=fragment_cache('injectBottom', function(){return injectHtml(theme.inject.bottom)})
|
||||||
|
!=partial('includes/chat/index', {}, {cache:theme.fragment_cache})
|
||||||
|
|
||||||
if theme.aplayerInject && !config.aplayer.asset_inject
|
if theme.aplayerInject && !config.aplayer.asset_inject
|
||||||
if theme.pjax
|
if theme.pjax
|
||||||
include ./head/aplayer.pug
|
include ./head/aplayer.pug
|
||||||
else if page.aplayer
|
else if page.aplayer
|
||||||
include ./head/aplayer.pug
|
include ./head/aplayer.pug
|
||||||
|
|
||||||
!=fragment_cache('injectBottom', function(){return injectHtml(theme.inject.bottom)})
|
|
||||||
!=partial('includes/chat/index', {}, {cache:theme.fragment_cache})
|
|
||||||
|
|
||||||
if theme.pjax
|
if theme.pjax
|
||||||
!=partial('includes/third-party/pjax', {}, {cache:theme.fragment_cache})
|
!=partial('includes/third-party/pjax', {}, {cache:theme.fragment_cache})
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
span=' '+label
|
span=' '+label
|
||||||
else
|
else
|
||||||
.menus_item
|
.menus_item
|
||||||
a.site-page
|
a.site-page(href='javascript:void(0);')
|
||||||
if label.split('||')[1]
|
if label.split('||')[1]
|
||||||
i.fa-fw(class=trim(label.split('||')[1]))
|
i.fa-fw(class=trim(label.split('||')[1]))
|
||||||
span=' '+ trim(label.split('||')[0])
|
span=' '+ trim(label.split('||')[0])
|
||||||
|
|||||||
@@ -7,9 +7,10 @@
|
|||||||
each item in theme.reward.QR_code
|
each item in theme.reward.QR_code
|
||||||
- var clickTo = (item.itemlist||item).link ? (item.itemlist||item).link : (item.itemlist||item).img
|
- var clickTo = (item.itemlist||item).link ? (item.itemlist||item).link : (item.itemlist||item).img
|
||||||
li.reward-item
|
li.reward-item
|
||||||
if theme.lazyload.enable
|
a(href=clickTo target='_blank')
|
||||||
img.post-qr-code-img(data-lazy-src=url_for((item.itemlist||item).img) alt=(item.itemlist||item).text onclick=`window.open('${url_for(clickTo)}')`)
|
if theme.lazyload.enable
|
||||||
else
|
img.post-qr-code-img(data-lazy-src=url_for((item.itemlist||item).img) alt=(item.itemlist||item).text)
|
||||||
img.post-qr-code-img(src=url_for((item.itemlist||item).img) alt=(item.itemlist||item).text onclick=`window.open('${url_for(clickTo)}')`)
|
else
|
||||||
|
img.post-qr-code-img(src=url_for((item.itemlist||item).img) alt=(item.itemlist||item).text)
|
||||||
.post-qr-code-desc=(item.itemlist||item).text
|
.post-qr-code-desc=(item.itemlist||item).text
|
||||||
|
|
||||||
|
|||||||
106
layout/includes/third-party/pjax.pug
vendored
106
layout/includes/third-party/pjax.pug
vendored
@@ -1,58 +1,56 @@
|
|||||||
script(src=url_for(theme.CDN.pjax))
|
script(src=url_for(theme.CDN.pjax))
|
||||||
script.
|
script.
|
||||||
$(function () {
|
var pjax = new Pjax({
|
||||||
var pjax = new Pjax({
|
elements: 'a:not([target="_blank"])',
|
||||||
selectors: [
|
selectors: [
|
||||||
'title',
|
'title',
|
||||||
'meta[name=description]',
|
'meta[name=description]',
|
||||||
'#config_change',
|
'#config_change',
|
||||||
'#body-wrap',
|
'#body-wrap',
|
||||||
'#rightside-config-hide',
|
'#rightside-config-hide',
|
||||||
'#rightside-config-show',
|
'#rightside-config-show',
|
||||||
'.js-pjax'
|
'.js-pjax'
|
||||||
],
|
],
|
||||||
cacheBust: false,
|
cacheBust: false,
|
||||||
})
|
})
|
||||||
|
|
||||||
document.addEventListener('pjax:complete', function () {
|
document.addEventListener('pjax:complete', function () {
|
||||||
refreshFn()
|
refreshFn()
|
||||||
|
|
||||||
$('script[data-pjax]').each(function () {
|
$('script[data-pjax]').each(function () {
|
||||||
$(this).parent().append($(this).remove())
|
$(this).parent().append($(this).remove())
|
||||||
})
|
})
|
||||||
|
|
||||||
GLOBAL_CONFIG.islazyload && lazyLoadInstance.update()
|
GLOBAL_CONFIG.islazyload && lazyLoadInstance.update()
|
||||||
|
|
||||||
typeof chatBtnFn === 'function' && chatBtnFn()
|
typeof chatBtnFn === 'function' && chatBtnFn()
|
||||||
typeof panguInit === 'function' && panguInit()
|
typeof panguInit === 'function' && panguInit()
|
||||||
|
|
||||||
if (typeof gtag === 'function') {
|
if (typeof gtag === 'function') {
|
||||||
gtag('config', '!{theme.google_analytics}', {'page_path': window.location.pathname});
|
gtag('config', '!{theme.google_analytics}', {'page_path': window.location.pathname});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (document.getElementsByClassName('aplayer').length){
|
typeof loadMeting === 'function' && document.getElementsByClassName('aplayer').length && loadMeting()
|
||||||
typeof loadMeting === 'function' && loadMeting()
|
|
||||||
}
|
})
|
||||||
})
|
|
||||||
|
document.addEventListener('pjax:send', function () {
|
||||||
document.addEventListener('pjax:send', function () {
|
if (window.aplayers) {
|
||||||
if (window.aplayers) {
|
for (let i = 0; i < window.aplayers.length; i++) {
|
||||||
for (let i = 0; i < window.aplayers.length; i++) {
|
if (!window.aplayers[i].options.fixed) {
|
||||||
if (!window.aplayers[i].options.fixed) {
|
window.aplayers[i].destroy()
|
||||||
window.aplayers[i].destroy()
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
typeof typed === 'object' && typed.destroy()
|
||||||
typeof typed === 'object' && typed.destroy()
|
|
||||||
|
$(window).off('scroll')
|
||||||
$(window).off('scroll')
|
|
||||||
|
//reset readmode
|
||||||
//reset readmode
|
$('body').hasClass('read-mode') && $('body').removeClass('read-mode')
|
||||||
$('body').hasClass('read-mode') && $('body').removeClass('read-mode')
|
|
||||||
|
//reset font-size
|
||||||
//reset font-size
|
$('body').css('font-size') !== originFontSize && $('body').css('font-size', parseFloat(originFontSize))
|
||||||
$('body').css('font-size') !== originFontSize && $('body').css('font-size', parseFloat(originFontSize))
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "hexo-theme-butterfly",
|
"name": "hexo-theme-butterfly",
|
||||||
"version": "3.0.0-pjax",
|
"version": "3.0.0-rc2-dev",
|
||||||
"private": true,
|
"private": true,
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=8.10.0"
|
"node": ">=8.10.0"
|
||||||
|
|||||||
@@ -8,15 +8,8 @@
|
|||||||
|
|
||||||
const urlFor = require('hexo-util').url_for.bind(hexo)
|
const urlFor = require('hexo-util').url_for.bind(hexo)
|
||||||
|
|
||||||
function lazyProcess (htmlContent) {
|
hexo.extend.filter.register('after_post_render', data => {
|
||||||
const bg = hexo.theme.config.lazyload.post ? urlFor(hexo.theme.config.lazyload.post) : 'data:image/gif;base64,R0lGODdhAQABAPAAAMPDwwAAACwAAAAAAQABAAACAkQBADs='
|
|
||||||
return htmlContent.replace(/(<img.*? src=)/ig, `$1 "${bg}" data-lazy-src=`)
|
|
||||||
}
|
|
||||||
|
|
||||||
const processPost = function (data) {
|
|
||||||
if (!hexo.theme.config.lazyload.enable) return
|
if (!hexo.theme.config.lazyload.enable) return
|
||||||
data.content = lazyProcess.call(this, data.content)
|
const bg = hexo.theme.config.lazyload.post ? urlFor(hexo.theme.config.lazyload.post) : 'data:image/gif;base64,R0lGODdhAQABAPAAAMPDwwAAACwAAAAAAQABAAACAkQBADs='
|
||||||
return data
|
return data.content.replace(/(<img.*? src=)/ig, `$1 "${bg}" data-lazy-src=`)
|
||||||
}
|
})
|
||||||
|
|
||||||
hexo.extend.filter.register('after_post_render', processPost)
|
|
||||||
|
|||||||
@@ -105,7 +105,6 @@ table
|
|||||||
color: #F7F7F7
|
color: #F7F7F7
|
||||||
|
|
||||||
button
|
button
|
||||||
margin: 0
|
|
||||||
padding: 0
|
padding: 0
|
||||||
outline: 0
|
outline: 0
|
||||||
border: none
|
border: none
|
||||||
|
|||||||
@@ -123,9 +123,6 @@ blockquote
|
|||||||
padding-left: .5rem
|
padding-left: .5rem
|
||||||
width: 100%
|
width: 100%
|
||||||
|
|
||||||
.line
|
|
||||||
height: 1rem
|
|
||||||
|
|
||||||
.highlight-tools
|
.highlight-tools
|
||||||
position: relative
|
position: relative
|
||||||
overflow: hidden
|
overflow: hidden
|
||||||
|
|||||||
@@ -69,5 +69,3 @@
|
|||||||
padding-top: .4rem
|
padding-top: .4rem
|
||||||
width: 130px
|
width: 130px
|
||||||
color: $reward-pop-up-color
|
color: $reward-pop-up-color
|
||||||
text-align: center
|
|
||||||
word-break: break-all
|
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ $text-highlight-color = $font-color
|
|||||||
$text-hover = $theme-color
|
$text-hover = $theme-color
|
||||||
$text-bg-hover = $theme-color
|
$text-bg-hover = $theme-color
|
||||||
// code
|
// code
|
||||||
$line-height-code-block = 20px
|
$line-height-code-block = 1.6
|
||||||
$blockquote-color = #6a737d
|
$blockquote-color = #6a737d
|
||||||
$blockquote-padding-color = $themeColorEnable ? convert(hexo-config('theme_color.blockquote_padding_color')) : #49B1F5
|
$blockquote-padding-color = $themeColorEnable ? convert(hexo-config('theme_color.blockquote_padding_color')) : #49B1F5
|
||||||
$blockquote-background-color = $themeColorEnable ? alpha(convert(hexo-config('theme_color.blockquote_background_color')), .1) : alpha($blockquote-padding-color, .1)
|
$blockquote-background-color = $themeColorEnable ? alpha(convert(hexo-config('theme_color.blockquote_background_color')), .1) : alpha($blockquote-padding-color, .1)
|
||||||
|
|||||||
Reference in New Issue
Block a user