diff --git a/.env.local b/.env.local index 35e50011..3eba4322 100644 --- a/.env.local +++ b/.env.local @@ -1,2 +1,2 @@ # 环境变量 @see https://www.nextjs.cn/docs/basic-features/environment-variables -NEXT_PUBLIC_VERSION=3.13.5 \ No newline at end of file +NEXT_PUBLIC_VERSION=4.0.6 \ 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/FlutteringRibbon.js b/components/FlutteringRibbon.js index 301fbd23..eb0f03e0 100644 --- a/components/FlutteringRibbon.js +++ b/components/FlutteringRibbon.js @@ -1,5 +1,5 @@ /* eslint-disable */ -import React from 'react' +import { useEffect } from 'react' const id = 'canvasFlutteringRibbon' export const FlutteringRibbon = () => { const destroyRibbon = ()=>{ @@ -9,15 +9,17 @@ export const FlutteringRibbon = () => { } } - React.useEffect(() => { + useEffect(() => { createFlutteringRibbon() return () => destroyRibbon() }, []) return <> - } +export default FlutteringRibbon + + /** * 创建连接点 * @param config 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/Gitalk.js b/components/Gitalk.js index 66b30174..166eb8c7 100644 --- a/components/Gitalk.js +++ b/components/Gitalk.js @@ -1,18 +1,44 @@ -import 'gitalk/dist/gitalk.css' +// import 'gitalk/dist/gitalk.css' import BLOG from '@/blog.config' -import GitalkComponent from 'gitalk/dist/gitalk-component' +import { loadExternalResource } from '@/lib/utils' +import { useEffect } from 'react' +// import GitalkComponent from 'gitalk/dist/gitalk-component' const Gitalk = ({ frontMatter }) => { - return + // return + const loadGitalk = async() => { + const css = await loadExternalResource(BLOG.COMMENT_GITALK_CSS_CDN_URL, 'css') + const js = await loadExternalResource(BLOG.COMMENT_GITALK_JS_CDN_URL, 'js') + + console.log('gitalk 加载成功', css, js) + const Gitalk = window.Gitalk + + const gitalk = new Gitalk({ + clientID: BLOG.COMMENT_GITALK_CLIENT_ID, + clientSecret: BLOG.COMMENT_GITALK_CLIENT_SECRET, + repo: BLOG.COMMENT_GITALK_REPO, + owner: BLOG.COMMENT_GITALK_OWNER, + admin: BLOG.COMMENT_GITALK_ADMIN.split(','), + id: frontMatter.id, // Ensure uniqueness and length less than 50 + distractionFreeMode: JSON.parse(BLOG.COMMENT_GITALK_DISTRACTION_FREE_MODE) // Facebook-like distraction free mode + }) + + gitalk.render('gitalk-container') + } + useEffect(() => { + loadGitalk() + }, []) + + return
} export default Gitalk diff --git a/components/GoogleAdsense.js b/components/GoogleAdsense.js index dd9ec543..9cdaa406 100644 --- a/components/GoogleAdsense.js +++ b/components/GoogleAdsense.js @@ -1,29 +1,98 @@ +import BLOG from '@/blog.config' +import { loadExternalResource } from '@/lib/utils' import { useRouter } from 'next/router' import { useEffect } from 'react' -export default function GoogleAdsense () { +/** + * 初始化谷歌广告 + * @returns + */ +export default function GoogleAdsense() { const initGoogleAdsense = () => { - const ads = document.getElementsByClassName('adsbygoogle').length - const newAdsCount = ads - if (newAdsCount > 0) { - for (let i = 0; i <= newAdsCount; i++) { - try { - // eslint-disable-next-line no-undef - (adsbygoogle = window.adsbygoogle || []).push({}) - } catch (e) { + // GoogleAdsense 本地开发请加入 data-adbreak-test="on" + // {BLOG.ADSENSE_GOOGLE_ID &&