mirror of
https://github.com/d0zingcat/NotionNext.git
synced 2026-05-14 07:26:52 +00:00
切换主题,更新busuanzi
This commit is contained in:
@@ -1,10 +1,15 @@
|
||||
import busuanzi from '@/lib/busuanzi'
|
||||
import { useRouter } from 'next/router'
|
||||
import { useEffect } from 'react'
|
||||
import { useGlobal } from '@/lib/global'
|
||||
// import { useRouter } from 'next/router'
|
||||
import React from 'react'
|
||||
|
||||
export default function Busuanzi () {
|
||||
const { theme } = useGlobal()
|
||||
const router = useRouter()
|
||||
useEffect(() => {
|
||||
|
||||
// 切换文章时更新
|
||||
React.useEffect(() => {
|
||||
const busuanziRouteChange = url => {
|
||||
busuanzi.fetch()
|
||||
}
|
||||
@@ -13,5 +18,12 @@ export default function Busuanzi () {
|
||||
router.events.off('routeChangeComplete', busuanziRouteChange)
|
||||
}
|
||||
}, [router.events])
|
||||
|
||||
// 更换主题时更新
|
||||
React.useEffect(() => {
|
||||
if (theme) {
|
||||
busuanzi.fetch()
|
||||
}
|
||||
})
|
||||
return null
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user