diff --git a/.env.local b/.env.local
index 8b04d2c7..48bf046f 100644
--- a/.env.local
+++ b/.env.local
@@ -1,2 +1,2 @@
# 环境变量 @see https://www.nextjs.cn/docs/basic-features/environment-variables
-NEXT_PUBLIC_VERSION=3.6.0
\ No newline at end of file
+NEXT_PUBLIC_VERSION=3.6.1
\ No newline at end of file
diff --git a/.eslintrc.js b/.eslintrc.js
index 6cf90e91..4b95adcd 100644
--- a/.eslintrc.js
+++ b/.eslintrc.js
@@ -16,7 +16,10 @@ module.exports = {
ecmaVersion: 12,
sourceType: 'module'
},
- plugins: ['react'],
+ plugins: [
+ 'react',
+ 'react-hooks'
+ ],
settings: {
react: {
version: 'detect'
@@ -24,7 +27,8 @@ module.exports = {
},
rules: {
'react/prop-types': 'off',
- 'space-before-function-paren': 0
+ 'space-before-function-paren': 0,
+ 'react-hooks/rules-of-hooks': 'error' // Checks rules of Hooks
},
globals: {
React: true
diff --git a/README.md b/README.md
index 14c81beb..df20f48e 100644
--- a/README.md
+++ b/README.md
@@ -117,6 +117,9 @@ yarn run start # 本地启动NextJS服务
 ifyz 🔧 🐛 |
+  SwwweetOrange 🔧 🐛 |
+
+
diff --git a/components/Busuanzi.js b/components/Busuanzi.js
index 12e592d8..fec41e5f 100644
--- a/components/Busuanzi.js
+++ b/components/Busuanzi.js
@@ -4,26 +4,23 @@ import { useGlobal } from '@/lib/global'
// import { useRouter } from 'next/router'
import React from 'react'
+let path = ''
+
export default function Busuanzi () {
const { theme } = useGlobal()
- const router = useRouter()
-
- // 切换文章时更新
- React.useEffect(() => {
- const busuanziRouteChange = url => {
+ const Router = useRouter()
+ Router.events.on('routeChangeComplete', (url, option) => {
+ if (url !== path) {
+ path = url
busuanzi.fetch()
}
- router.events.on('routeChangeComplete', busuanziRouteChange)
- return () => {
- router.events.off('routeChangeComplete', busuanziRouteChange)
- }
- }, [router.events])
+ })
// 更换主题时更新
React.useEffect(() => {
if (theme) {
busuanzi.fetch()
}
- })
+ }, [theme])
return null
}
diff --git a/components/Comment.js b/components/Comment.js
index d362e047..c1ae3d2b 100644
--- a/components/Comment.js
+++ b/components/Comment.js
@@ -43,9 +43,6 @@ const ValineComponent = dynamic(() => import('@/components/ValineComponent'), {
})
const Comment = ({ frontMatter }) => {
- if (!frontMatter) {
- return <>Loading...>
- }
const { isDarkMode } = useGlobal()
const router = useRouter()
@@ -61,6 +58,10 @@ const Comment = ({ frontMatter }) => {
}, 200)
}, [])
+ if (!frontMatter) {
+ return <>Loading...>
+ }
+
return (