From 439014bbb625e80418d60f3a9d4ddc1111aba920 Mon Sep 17 00:00:00 2001 From: Jerry Date: Fri, 7 Nov 2025 22:19:16 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20=E5=8D=87=E7=B4=9A=E7=89=88=E6=9C=AC?= =?UTF-8?q?=E8=87=B3=205.5.2=20=E4=B8=A6=E6=9B=B4=E6=96=B0=E7=9B=B8?= =?UTF-8?q?=E4=BE=9D=E5=A5=97=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - perf(highlight): 改善複製提示 UI,新增浮動動畫效果 - fix(shuoshuo): 為說說內容中的圖片新增延遲載入支援 - fix(mermaid): 支援在標籤助手中使用自訂配置選項 - fix: 使用 url_for() 處理主題資源路徑 (busuanzi, artalk) - refactor(aside_archives): 重新命名 url_for 變數以保持一致性 - refactor(inject_head_js): 使用解構賦值命名方式 - chore(deps): 更新 hexo-util 至 4.0.0 - chore(plugins): 更新多個 CDN 套件版本 - style(highlight): 優化程式碼區塊工具列佈局與溢位處理 - fix(zh-CN): 修正分頁文字使用正確的簡體字「页」 --- layout/includes/additional-js.pug | 2 +- layout/includes/page/shuoshuo.pug | 33 ++++++++++++- .../includes/third-party/comments/artalk.pug | 4 +- layout/includes/third-party/math/mermaid.pug | 6 ++- package.json | 4 +- plugins.yml | 26 +++++------ scripts/helpers/aside_archives.js | 6 +-- scripts/helpers/inject_head_js.js | 6 +-- scripts/tag/mermaid.js | 3 +- source/css/_highlight/highlight.styl | 46 +++++++++++-------- source/js/main.js | 41 ++++++++++++++--- 11 files changed, 125 insertions(+), 52 deletions(-) diff --git a/layout/includes/additional-js.pug b/layout/includes/additional-js.pug index 9bae95a..6c8874e 100644 --- a/layout/includes/additional-js.pug +++ b/layout/includes/additional-js.pug @@ -52,7 +52,7 @@ div != partial("includes/third-party/umami_analytics", {}, { cache: true }) if theme.busuanzi.site_uv || theme.busuanzi.site_pv || theme.busuanzi.page_pv - script(async data-pjax src= theme.asset.busuanzi || '//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js') + script(async data-pjax src=url_for(theme.asset.busuanzi) || '//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js') != partial('includes/third-party/search/index', {}, { cache: true }) diff --git a/layout/includes/page/shuoshuo.pug b/layout/includes/page/shuoshuo.pug index ee36041..3e5f15b 100644 --- a/layout/includes/page/shuoshuo.pug +++ b/layout/includes/page/shuoshuo.pug @@ -49,6 +49,7 @@ if !page.shuoshuo_url script(type='application/json' id='shuoshuo-data')!= safeJSON(localDate) + - const { enable, native, placeholder, field } = theme.lazyload script. (() => { const limitConfig = !{ JSON.stringify(page.limit || {}) } @@ -84,6 +85,36 @@ return `${year}-${month}-${day} ${hour}:${minute}:${second}` } + const addLazyload = str => { + const config = { + enable: !{Boolean(enable)}, + native: !{Boolean(native)}, + field: '!{field}', + placeholder: '!{url_for(placeholder)}', + } + + if (!config.enable || config.field !== 'site') return str + const parser = new DOMParser() + const doc = parser.parseFromString(str, 'text/html') + const images = doc.querySelectorAll('img') + + images.forEach(img => { + if (config.native) { + img.setAttribute('loading', 'lazy') + } else { + const src = img.getAttribute('src') + img.setAttribute('data-lazy-src', src) + + if (config.placeholder) { + img.setAttribute('src', config.placeholder) + } else { + img.removeAttribute('src') + } + } + }) + return doc.body.innerHTML + } + let currentPage = 1 const itemsPerPage = 8 let totalPages = 0 @@ -117,7 +148,7 @@ -
${item.content}
+
${addLazyload(item.content)}