fukasawa - adsense

This commit is contained in:
tangly1024.com
2023-07-10 12:58:43 +08:00
parent 8afdf975b1
commit 93ae243279
5 changed files with 29 additions and 8 deletions

View File

@@ -2,6 +2,10 @@ import BLOG from '@/blog.config'
import { useRouter } from 'next/router'
import { useEffect } from 'react'
/**
* 初始化谷歌广告
* @returns
*/
export default function GoogleAdsense() {
const initGoogleAdsense = () => {
setTimeout(() => {
@@ -21,12 +25,8 @@ export default function GoogleAdsense() {
}
const router = useRouter()
useEffect(() => {
router.events.on('routeChangeComplete', initGoogleAdsense)
return () => {
router.events.off('routeChangeComplete', initGoogleAdsense)
}
initGoogleAdsense()
}, [router])
return null