From 71756ea0911c350bdb24b809ad9a8c7352822134 Mon Sep 17 00:00:00 2001 From: zkz098 Date: Mon, 24 Jun 2024 14:42:48 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=9D=82=E9=A1=B9=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 2 +- scripts/plugin/index.ts | 4 +++- source/js/_app/pjax/refresh.ts | 43 ++++++++++++++++++---------------- 3 files changed, 27 insertions(+), 22 deletions(-) diff --git a/package.json b/package.json index 93fd6d6..012937e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "hexo-theme-shokax", - "version": "0.4.3", + "version": "0.4.4", "description": "a hexo theme based on shoka", "main": "index.js", "repository": "https://github.com/theme-shoka-x/hexo-theme-shokaX", diff --git a/scripts/plugin/index.ts b/scripts/plugin/index.ts index a5f3490..393f2ef 100644 --- a/scripts/plugin/index.ts +++ b/scripts/plugin/index.ts @@ -22,7 +22,9 @@ hexo.on('generateBefore', () => { hexo.on('generateAfter', () => { // 检查版本更新 - fetch('https://api.shokax.top/version/hexo').then((res) => { + fetch('https://api.shokax.top/version/hexo', {headers: { + "User-Agent": "Mozilla/5.0 ShokaX Client (hexo-theme-shokax)" + }}).then((res) => { res.json().then((resp) => { try { const latest = resp['version'] diff --git a/source/js/_app/pjax/refresh.ts b/source/js/_app/pjax/refresh.ts index c499f57..5a98382 100644 --- a/source/js/_app/pjax/refresh.ts +++ b/source/js/_app/pjax/refresh.ts @@ -76,29 +76,32 @@ export const siteRefresh = (reload) => { postBeauty() }) - const comment = new IntersectionObserver((entries) => { - entries.forEach((entry) => { - if (entry.isIntersecting) { - if (__shokax_waline__) { - import('../components/comments').then(({ walinePageview, walineComment }) => { - walinePageview() - walineComment() - }) - } - if (__shokax_twikoo__) { - import('../components/tcomments').then(({ twikooComment }) => { - twikooComment() - }) + const cpel = $dom('#copyright') + if (cpel) { + const comment = new IntersectionObserver((entries) => { + entries.forEach((entry) => { + if (entry.isIntersecting) { + if (__shokax_waline__) { + import('../components/comments').then(({walinePageview, walineComment}) => { + walinePageview() + walineComment() + }) + } + if (__shokax_twikoo__) { + import('../components/tcomments').then(({twikooComment}) => { + twikooComment() + }) + } + comment.disconnect() } - comment.disconnect() - } + }) + }, { + root: null, + threshold: 0.2 }) - }, { - root: null, - threshold: 0.2 - }) - comment.observe($dom('#copyright')) + comment.observe(cpel) + } lazyLoad()