diff --git a/.env.local b/.env.local index fc777115..1283ba60 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.16.4 \ No newline at end of file +NEXT_PUBLIC_VERSION=4.0.0 \ 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 83ffc006..d9718369 100644 --- a/components/GoogleAdsense.js +++ b/components/GoogleAdsense.js @@ -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 diff --git a/components/HeroIcons.js b/components/HeroIcons.js new file mode 100644 index 00000000..6a24d8b7 --- /dev/null +++ b/components/HeroIcons.js @@ -0,0 +1,94 @@ +/** + * @see https://heroicons.com/ + * @returns + */ + +export const Moon = () => { + return +} + +export const Sun = () => { + return +} + +export const Home = ({ className }) => { + return +} + +export const User = ({ className }) => { + return +} + +export const ArrowPath = ({ className }) => { + return +} + +export const ChevronLeft = ({ className }) => { + return +} + +export const ChevronRight = ({ className }) => { + return +} + +export const ChevronDoubleRight = ({ className }) => { + return +} + +export const InformationCircle = ({ className }) => { + return +} + +export const HashTag = ({ className }) => { + return +} + +export const GlobeAlt = ({ className }) => { + return +} + +export const ArrowRightCircle = ({ className }) => { + return +} + +export const PlusSmall = ({ className }) => { + return +} + +export const ArrowSmallRight = ({ className }) => { + return +} + +export const ArrowSmallUp = ({ className }) => { + return +} diff --git a/components/NotionPage.js b/components/NotionPage.js index e389468f..e559bdbb 100644 --- a/components/NotionPage.js +++ b/components/NotionPage.js @@ -1,12 +1,14 @@ import { NotionRenderer } from 'react-notion-x' import dynamic from 'next/dynamic' -// import mediumZoom from '@fisch0920/medium-zoom' -import React, { useEffect } from 'react' +import mediumZoom from '@fisch0920/medium-zoom' +import React, { useEffect, useRef } from 'react' // import { Code } from 'react-notion-x/build/third-party/code' import TweetEmbed from 'react-tweet-embed' import 'katex/dist/katex.min.css' import { mapImgUrl } from '@/lib/notion/mapImage' +import BLOG from '@/blog.config' +import { isBrowser } from '@/lib/utils' const Code = dynamic(() => import('react-notion-x/build/third-party/code').then(async (m) => { @@ -21,6 +23,7 @@ const Equation = dynamic(() => return m.Equation }), { ssr: false } ) + const Pdf = dynamic( () => import('react-notion-x/build/third-party/pdf').then((m) => m.Pdf), { @@ -51,11 +54,39 @@ const NotionPage = ({ post, className }) => { autoScrollToTarget() }, []) + const zoom = typeof window !== 'undefined' && mediumZoom({ + container: '.notion-viewport', + background: 'rgba(0, 0, 0, 0.2)', + margin: getMediumZoomMargin() + }) + const zoomRef = useRef(zoom ? zoom.clone() : null) + + useEffect(() => { + // 将相册gallery下的图片加入放大功能 + if (JSON.parse(BLOG.POST_DISABLE_GALLERY_CLICK)) { + setTimeout(() => { + if (isBrowser()) { + const imgList = document?.querySelectorAll('.notion-collection-card-cover img') + if (imgList && zoomRef.current) { + for (let i = 0; i < imgList.length; i++) { + (zoomRef.current).attach(imgList[i]) + } + } + + const cards = document.getElementsByClassName('notion-collection-card') + for (const e of cards) { + e.removeAttribute('href') + } + } + }, 800) + } + }, []) + if (!post || !post.blockMap) { return <>{post?.summary || ''}> } - return