Skip to content

Commit

Permalink
切换主题,更新busuanzi
Browse files Browse the repository at this point in the history
  • Loading branch information
tangly1024 committed Nov 8, 2022
1 parent 8b5ecdb commit a27413d
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions components/Busuanzi.js
Original file line number Diff line number Diff line change
@@ -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()
}
Expand All @@ -13,5 +18,12 @@ export default function Busuanzi () {
router.events.off('routeChangeComplete', busuanziRouteChange)
}
}, [router.events])

// 更换主题时更新
React.useEffect(() => {
if (theme) {
busuanzi.fetch()
}
})
return null
}

0 comments on commit a27413d

Please sign in to comment.