diff --git a/components/CustomContextMenu.js b/components/CustomContextMenu.js index 74fafbe8..8402f20e 100644 --- a/components/CustomContextMenu.js +++ b/components/CustomContextMenu.js @@ -57,12 +57,10 @@ export default function CustomContextMenu(props) { } /** - * 鼠标点击事件 + * 鼠标点击即关闭菜单 */ const handleClick = event => { - if (menuRef.current && !menuRef.current.contains(event.target)) { - setShow(false) - } + setShow(false) } window.addEventListener('contextmenu', handleContextMenu) @@ -88,7 +86,6 @@ export default function CustomContextMenu(props) { function handleScrollTop() { window.scrollTo({ top: 0, behavior: 'smooth' }) - setShow(false) } function handleCopyLink() { @@ -96,12 +93,12 @@ export default function CustomContextMenu(props) { navigator.clipboard .writeText(url) .then(() => { - console.log('页面地址已复制') + // console.log('页面地址已复制') + alert(`${locale.COMMON.PAGE_URL_COPIED} : ${url}`) }) .catch(error => { console.error('复制页面地址失败:', error) }) - setShow(false) } /** @@ -130,8 +127,6 @@ export default function CustomContextMenu(props) { } else { // alert("Please select some text first."); } - - setShow(false) } function handleChangeDarkMode() { diff --git a/lib/lang/en-US.js b/lib/lang/en-US.js index 985e0a24..49339220 100644 --- a/lib/lang/en-US.js +++ b/lib/lang/en-US.js @@ -37,6 +37,7 @@ export default { ARTICLE: 'Article', VISITORS: 'Visitors', VIEWS: 'Views', + PAGE_URL_COPIED: 'Page URL copied', COPYRIGHT_NOTICE: 'All articles in this blog, except for special statements, adopt BY-NC-SA agreement. Please indicate the source!', RESULT_OF_SEARCH: 'Results Found', diff --git a/lib/lang/zh-CN.js b/lib/lang/zh-CN.js index e38a27bf..827f376f 100644 --- a/lib/lang/zh-CN.js +++ b/lib/lang/zh-CN.js @@ -39,6 +39,7 @@ export default { ARTICLE: '文章', VISITORS: '位访客', VIEWS: '次查看', + PAGE_URL_COPIED: '页面地址已复制', COPYRIGHT_NOTICE: '本文采用 CC BY-NC-SA 4.0 许可协议,转载请注明出处。', RESULT_OF_SEARCH: '篇搜索到的结果', NO_RESULTS_FOUND: '没有找到文章', diff --git a/themes/heo/components/Footer.js b/themes/heo/components/Footer.js index 8a4499a8..a4018b74 100644 --- a/themes/heo/components/Footer.js +++ b/themes/heo/components/Footer.js @@ -1,49 +1,66 @@ -import SocialButton from './SocialButton' import { siteConfig } from '@/lib/config' +import SocialButton from './SocialButton' const Footer = ({ title }) => { const d = new Date() const currentYear = d.getFullYear() const since = siteConfig('SINCE') - const copyrightDate = parseInt(since) < currentYear ? since + '-' + currentYear : currentYear + const copyrightDate = + parseInt(since) < currentYear ? since + '-' + currentYear : currentYear return ( - ) } diff --git a/themes/heo/components/PostAdjacent.js b/themes/heo/components/PostAdjacent.js index b854e946..aa61d3f8 100644 --- a/themes/heo/components/PostAdjacent.js +++ b/themes/heo/components/PostAdjacent.js @@ -10,21 +10,28 @@ import CONFIG from '../config' * @returns */ export default function PostAdjacent({ prev, next }) { - const [isScrollEnd, setIsScrollEnd] = useState(false) + const [isShow, setIsShow] = useState(false) const router = useRouter() useEffect(() => { - setIsScrollEnd(false) + setIsShow(false) }, [router]) useEffect(() => { - // 文章是否已经到了底部 - const targetElement = document.getElementById('article-end') + // 文章到底部时显示下一篇文章推荐 + const articleEnd = document.getElementById('article-end') + const footerBottom = document.getElementById('footer-bottom') const handleIntersect = entries => { entries.forEach(entry => { - if (entry.isIntersecting) { - setIsScrollEnd(true) + if (entry.target === articleEnd) { + if (entry.isIntersecting) { + setIsShow(true) + } + } else if (entry.target === footerBottom) { + if (entry.isIntersecting) { + setIsShow(false) + } } }) } @@ -36,9 +43,12 @@ export default function PostAdjacent({ prev, next }) { } const observer = new IntersectionObserver(handleIntersect, options) - observer.observe(targetElement) + if (articleEnd) observer.observe(articleEnd) + if (footerBottom) observer.observe(footerBottom) return () => { + if (articleEnd) observer.unobserve(articleEnd) + if (footerBottom) observer.unobserve(footerBottom) observer.disconnect() } }, []) @@ -75,7 +85,7 @@ export default function PostAdjacent({ prev, next }) {
+ className={`hidden md:block fixed z-40 right-24 bottom-4 duration-200 transition-all ${isShow ? 'mb-0 opacity-100' : '-mb-24 opacity-0'}`}> diff --git a/themes/heo/index.js b/themes/heo/index.js index bd2fb42b..ae0b21d8 100644 --- a/themes/heo/index.js +++ b/themes/heo/index.js @@ -311,12 +311,13 @@ const LayoutSlug = props => { {/* 文章推荐 */} - {/* 上一篇\下一篇文章 */} -
)} + {/* 上一篇\下一篇文章 */} + + {fullWidth ? null : (

@@ -337,6 +338,7 @@ const LayoutSlug = props => {
)} + )