不蒜子调整
This commit is contained in:
tangly1024
2021-12-21 13:55:42 +08:00
parent e430d55cf8
commit ac7ff2e912
7 changed files with 153 additions and 47 deletions

View File

@@ -6,29 +6,17 @@ import 'rc-dropdown/assets/index.css'
import 'prismjs/themes/prism-okaidia.css'
import 'katex/dist/katex.min.css'
import dynamic from 'next/dynamic'
import { GlobalContextProvider, handleRouteChange } from '@/lib/global'
import { useEffect } from 'react'
import { useRouter } from 'next/router'
import { GlobalContextProvider } from '@/lib/global'
import { config } from '@fortawesome/fontawesome-svg-core'
import '@fortawesome/fontawesome-svg-core/styles.css'
config.autoAddCss = false
const Ackee = dynamic(() => import('@/components/Ackee'), { ssr: false })
const Gtag = dynamic(() => import('@/components/Gtag'), { ssr: false })
const Busuanzi = dynamic(() => import('@/components/Busuanzi'), { ssr: false })
const GoogleAdsense = dynamic(() => import('@/components/GoogleAdsense'), { ssr: false })
const MyApp = ({ Component, pageProps }) => {
// 全局监听路由变化
const router = useRouter()
useEffect(() => {
handleRouteChange(router.pathname)
const routerListener = (url) => {
handleRouteChange(url)
}
router.events.on('routeChangeComplete', routerListener)
return () => {
router.events.off('routeChangeComplete', routerListener)
}
})
return (
<GlobalContextProvider>
{BLOG.isProd && BLOG?.analytics?.provider === 'ackee' && (
@@ -38,6 +26,8 @@ const MyApp = ({ Component, pageProps }) => {
/>
)}
{BLOG.isProd && BLOG?.analytics?.provider === 'ga' && <Gtag />}
{BLOG.analytics.busuanzi && <Busuanzi/>}
{BLOG.googleAdsenseId && <GoogleAdsense/>}
<Component {...pageProps} />
</GlobalContextProvider>
)