diff --git a/.env.local b/.env.local index 1283ba60..f1644143 100644 --- a/.env.local +++ b/.env.local @@ -1,2 +1,2 @@ # 环境变量 @see https://www.nextjs.cn/docs/basic-features/environment-variables -NEXT_PUBLIC_VERSION=4.0.0 \ No newline at end of file +NEXT_PUBLIC_VERSION=4.0.5 \ No newline at end of file diff --git a/.eslintrc.js b/.eslintrc.js index 4b95adcd..bab5ea27 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -26,6 +26,7 @@ module.exports = { } }, rules: { + 'react/no-unknown-property': 'off', // + + ) +} diff --git a/components/FullScreenButton.js b/components/FullScreenButton.js new file mode 100644 index 00000000..053de666 --- /dev/null +++ b/components/FullScreenButton.js @@ -0,0 +1,48 @@ +import { isBrowser } from '@/lib/utils' +import React, { useState } from 'react' + +/** + * 全屏按钮 + * @returns + */ +const FullScreenButton = () => { + const [isFullScreen, setIsFullScreen] = useState(false) + + const handleFullScreenClick = () => { + if (!isBrowser()) { + return + } + const element = document.documentElement + if (!isFullScreen) { + if (element.requestFullscreen) { + element.requestFullscreen() + } else if (element.webkitRequestFullscreen) { + element.webkitRequestFullscreen() + } else if (element.mozRequestFullScreen) { + element.mozRequestFullScreen() + } else if (element.msRequestFullscreen) { + element.msRequestFullscreen() + } + setIsFullScreen(true) + } else { + if (document.exitFullscreen) { + document.exitFullscreen() + } else if (document.webkitExitFullscreen) { + document.webkitExitFullscreen() + } else if (document.mozCancelFullScreen) { + document.mozCancelFullScreen() + } else if (document.msExitFullscreen) { + document.msExitFullscreen() + } + setIsFullScreen(false) + } + } + + return ( + + ) +} + +export default FullScreenButton diff --git a/components/GoogleAdsense.js b/components/GoogleAdsense.js index d9718369..9cdaa406 100644 --- a/components/GoogleAdsense.js +++ b/components/GoogleAdsense.js @@ -1,4 +1,5 @@ import BLOG from '@/blog.config' +import { loadExternalResource } from '@/lib/utils' import { useRouter } from 'next/router' import { useEffect } from 'react' @@ -8,25 +9,35 @@ import { useEffect } from 'react' */ export default function GoogleAdsense() { const initGoogleAdsense = () => { - setTimeout(() => { - const ads = document.getElementsByClassName('adsbygoogle') - const adsbygoogle = window.adsbygoogle - if (ads.length > 0) { - for (let i = 0; i <= ads.length; i++) { - try { - adsbygoogle.push(ads[i]) - console.log('adsbygoogle', i, ads[i], adsbygoogle) - } catch (e) { + // GoogleAdsense 本地开发请加入 data-adbreak-test="on" + // {BLOG.ADSENSE_GOOGLE_ID &&