From 9afacdc8e857219ac40221506f5ecf7ccb0614ef Mon Sep 17 00:00:00 2001 From: "tangly1024.com" Date: Wed, 29 May 2024 10:51:56 +0800 Subject: [PATCH 1/8] =?UTF-8?q?heo=20=E4=B8=BB=E9=A2=98=E6=A0=B7=E5=BC=8F?= =?UTF-8?q?=E3=80=81=E4=BA=A4=E4=BA=92=E5=BE=AE=E8=B0=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/CustomContextMenu.js | 13 ++--- lib/lang/en-US.js | 1 + lib/lang/zh-CN.js | 1 + themes/heo/components/Footer.js | 79 ++++++++++++++++----------- themes/heo/components/PostAdjacent.js | 26 ++++++--- themes/heo/index.js | 6 +- 6 files changed, 76 insertions(+), 50 deletions(-) diff --git a/components/CustomContextMenu.js b/components/CustomContextMenu.js index 74fafbe8a83..8402f20e55a 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 985e0a24e54..49339220ca9 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 e38a27bf669..827f376fd97 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 8a4499a8404..a4018b7456f 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 b854e946a34..aa61d3f8d95 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 bd2fb42bdaf..ae0b21d8210 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 => {
)} + ) From 4fb7bf2f9c3233bc8e7eb5e8a4495b5cb0b5b4ea Mon Sep 17 00:00:00 2001 From: "tangly1024.com" Date: Wed, 29 May 2024 10:54:06 +0800 Subject: [PATCH 2/8] =?UTF-8?q?=E5=9B=BE=E7=89=87=E5=8A=A0=E8=BD=BD?= =?UTF-8?q?=E5=BC=82=E5=B8=B8=E5=8D=A0=E4=BD=8D=E5=9B=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/LazyImage.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/components/LazyImage.js b/components/LazyImage.js index 4e353ad8527..73a20f89dde 100644 --- a/components/LazyImage.js +++ b/components/LazyImage.js @@ -20,6 +20,8 @@ export default function LazyImage({ style }) { const maxWidth = siteConfig('IMAGE_COMPRESS_WIDTH') + const defaultPlaceholderSrc = siteConfig('IMG_LAZY_LOAD_PLACEHOLDER') + const imageRef = useRef(null) const [adjustedSrc, setAdjustedSrc] = useState( placeholderSrc || siteConfig('IMG_LAZY_LOAD_PLACEHOLDER') @@ -37,6 +39,14 @@ export default function LazyImage({ onLoad() // 触发传递的onLoad回调函数 } } + /** + * 图片加载失败回调 + */ + const handleImageError = () => { + if (imageRef.current) { + imageRef.current.src = defaultPlaceholderSrc + } + } useEffect(() => { const adjustedImageSrc = adjustImgSize(src, maxWidth) @@ -71,7 +81,8 @@ export default function LazyImage({ ref: imageRef, src: priority ? adjustedSrc : placeholderSrc, alt: alt, - onLoad: handleImageLoad + onLoad: handleImageLoad, + onError: handleImageError // 添加onError处理函数 } if (id) { From 36ec6deba9c555d14284510d5c17116ae61f30f7 Mon Sep 17 00:00:00 2001 From: "tangly1024.com" Date: Wed, 29 May 2024 11:03:37 +0800 Subject: [PATCH 3/8] =?UTF-8?q?HEO=E6=96=87=E7=AB=A0=E5=A4=9A=E4=BD=99?= =?UTF-8?q?=E6=BB=9A=E5=8A=A8=E6=9D=A1=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- themes/heo/index.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/themes/heo/index.js b/themes/heo/index.js index ae0b21d8210..619bb90dc6c 100644 --- a/themes/heo/index.js +++ b/themes/heo/index.js @@ -284,18 +284,18 @@ const LayoutSlug = props => { return ( <>
+ className={`article h-full w-full ${fullWidth ? '' : 'xl:max-w-5xl'} ${hasCode ? 'xl:w-[73.15vw]' : ''} lg:hover:shadow lg:border rounded-2xl lg:px-2 lg:py-4 bg-white dark:bg-[#18171d] dark:border-gray-600`}> + {/* 文章锁 */} {lock && } {!lock && ( -
+
+ {/* 文章主体 */}
+ className='wow fadeInUp'> {/* Notion文章主体 */}
@@ -318,6 +318,7 @@ const LayoutSlug = props => { {/* 上一篇\下一篇文章 */} + {/* 评论区 */} {fullWidth ? null : (

From 0f9de3aa3820490039182e26fb2a8b5c77d7f15c Mon Sep 17 00:00:00 2001 From: "tangly1024.com" Date: Wed, 29 May 2024 11:10:26 +0800 Subject: [PATCH 4/8] =?UTF-8?q?heo=20=E5=AF=BC=E8=88=AA=E6=A0=8F=E5=8A=A8?= =?UTF-8?q?=E7=94=BB=E7=BB=86=E8=8A=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- themes/heo/components/Header.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/themes/heo/components/Header.js b/themes/heo/components/Header.js index 35b6f058de0..c23cb81faab 100644 --- a/themes/heo/components/Header.js +++ b/themes/heo/components/Header.js @@ -158,7 +158,7 @@ const Header = props => {
{/* 右侧固定 */} -
+
{!JSON.parse(siteConfig('THEME_SWITCH')) && ( From 2372ddef4e55b25e724d549f0ceb659a683d48b2 Mon Sep 17 00:00:00 2001 From: "tangly1024.com" Date: Wed, 29 May 2024 11:49:31 +0800 Subject: [PATCH 5/8] =?UTF-8?q?heo=20=E4=B8=BB=E9=A2=98=E4=B8=80=E7=82=B9?= =?UTF-8?q?=E7=BB=86=E8=8A=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- themes/heo/components/PaginationNumber.js | 6 +++--- themes/heo/components/PostHeader.js | 14 ++++++++------ themes/heo/components/SideRight.js | 7 +++++-- themes/heo/index.js | 4 ++-- 4 files changed, 18 insertions(+), 13 deletions(-) diff --git a/themes/heo/components/PaginationNumber.js b/themes/heo/components/PaginationNumber.js index 5110064ecce..0ffc7bfbdf0 100644 --- a/themes/heo/components/PaginationNumber.js +++ b/themes/heo/components/PaginationNumber.js @@ -56,7 +56,7 @@ const PaginationNumber = ({ page, totalPage }) => { }} rel='prev' className={`${currentPage === 1 ? 'invisible' : 'block'}`}> -
+
{locale.PAGINATION.PREV} @@ -69,7 +69,7 @@ const PaginationNumber = ({ page, totalPage }) => { {pages} {/* 跳转页码 */} -
+
{ }} rel='next' className={`${+showNext ? 'block' : 'invisible'} `}> -
+
{locale.PAGINATION.NEXT} diff --git a/themes/heo/components/PostHeader.js b/themes/heo/components/PostHeader.js index f2aa5e9b5ae..d34faca5a4c 100644 --- a/themes/heo/components/PostHeader.js +++ b/themes/heo/components/PostHeader.js @@ -12,7 +12,7 @@ import WavesArea from './WavesArea' * @param {*} param0 * @returns */ -export default function PostHeader({ post, siteInfo }) { +export default function PostHeader({ post, siteInfo, isDarkMode }) { if (!post) { return <> } @@ -31,19 +31,21 @@ export default function PostHeader({ post, siteInfo }) { height: 100%; top: 0; left: 0; - box-shadow: 110px -130px 300px 60px #0060e0 inset; + box-shadow: 110px -130px 500px 100px ${isDarkMode + ? '#CA8A04' + : '#0060e0'} inset; } `}
+ className={`${isDarkMode ? 'bg-[#CA8A04]' : 'bg-[#0060e0]'} absolute top-0 w-full h-full py-10 flex justify-center items-center`}> {/* 文章背景图 */}
@@ -61,7 +61,10 @@ export default function SideRight(props) { {/* 标签和成绩 */} - +
diff --git a/themes/heo/index.js b/themes/heo/index.js index 619bb90dc6c..8e19a166a52 100644 --- a/themes/heo/index.js +++ b/themes/heo/index.js @@ -52,7 +52,7 @@ const LayoutBase = props => { const { children, slotTop, className } = props // 全屏模式下的最大宽度 - const { fullWidth } = useGlobal() + const { fullWidth, isDarkMode } = useGlobal() const router = useRouter() const headerSlot = ( @@ -67,7 +67,7 @@ const LayoutBase = props => { ) : null} - {fullWidth ? null : } + {fullWidth ? null : } ) From f7258fd2c66c44756e3479ccd7dc85f07d4bbacb Mon Sep 17 00:00:00 2001 From: "tangly1024.com" Date: Wed, 29 May 2024 14:25:58 +0800 Subject: [PATCH 6/8] =?UTF-8?q?heo=20=E4=B8=BB=E9=A2=98=20=E4=B8=80?= =?UTF-8?q?=E7=82=B9=E7=82=B9=E7=BB=86=E8=8A=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/lang/en-US.js | 3 + lib/lang/zh-CN.js | 3 + styles/notion.css | 1 + themes/heo/components/BlogPostCard.js | 4 +- themes/heo/components/CategoryBar.js | 50 +++-- themes/heo/components/Hero.js | 15 +- themes/heo/components/LatestPostsGroupMini.js | 6 +- themes/heo/components/MenuItemCollapse.js | 4 +- themes/heo/components/MenuItemDrop.js | 4 +- themes/heo/components/MenuListSide.js | 2 +- themes/heo/components/NoticeBar.js | 23 +- themes/heo/components/PostHeader.js | 11 +- themes/heo/components/SlideOver.js | 204 ++++++++++-------- themes/heo/components/TagItemMini.js | 9 +- 14 files changed, 203 insertions(+), 136 deletions(-) diff --git a/lib/lang/en-US.js b/lib/lang/en-US.js index 49339220ca9..f60b375ae13 100644 --- a/lib/lang/en-US.js +++ b/lib/lang/en-US.js @@ -33,6 +33,9 @@ export default { COPYRIGHT: 'Copyright', AUTHOR: 'Author', URL: 'URL', + NOW: 'NOW', + RECOMMEND_BADGES: 'Recommend', + BLOG: 'Blog', POSTS: 'Posts', ARTICLE: 'Article', VISITORS: 'Visitors', diff --git a/lib/lang/zh-CN.js b/lib/lang/zh-CN.js index 827f376fd97..4dd1962e764 100644 --- a/lib/lang/zh-CN.js +++ b/lib/lang/zh-CN.js @@ -35,6 +35,9 @@ export default { AUTHOR: '作者', URL: '链接', ANALYTICS: '统计', + RECOMMEND_BADGES: '荐', + BLOG: '博客', + NOW: '此刻', POSTS: '篇文章', ARTICLE: '文章', VISITORS: '位访客', diff --git a/styles/notion.css b/styles/notion.css index e5f8c14ff1b..ba794f88772 100644 --- a/styles/notion.css +++ b/styles/notion.css @@ -1451,6 +1451,7 @@ code[class*='language-'] { .notion-collection-card-property .notion-page-title-text { border-bottom: 0 none; + @apply dark:text-gray-200; } .notion-collection-card-property diff --git a/themes/heo/components/BlogPostCard.js b/themes/heo/components/BlogPostCard.js index 3a1cf6893a6..b26256e4d27 100644 --- a/themes/heo/components/BlogPostCard.js +++ b/themes/heo/components/BlogPostCard.js @@ -50,11 +50,11 @@ const BlogPostCard = ({ index, post, showSummary, siteInfo }) => { {/* 分类 */} {post?.category && ( diff --git a/themes/heo/components/CategoryBar.js b/themes/heo/components/CategoryBar.js index eccd9685621..9879d8a78cd 100644 --- a/themes/heo/components/CategoryBar.js +++ b/themes/heo/components/CategoryBar.js @@ -29,23 +29,40 @@ export default function CategoryBar(props) { } } - return
+
+ + {categoryOptions?.map((c, index) => ( + + ))} +
-
- - {categoryOptions?.map((c, index) => )} -
- -
- - - {locale.MENU.CATEGORY} - +
+ + + {locale.MENU.CATEGORY} + +
+ ) } /** @@ -57,7 +74,10 @@ const MenuItem = ({ href, name }) => { const router = useRouter() const { category } = router.query const selected = category === name - return
- {name} + return ( +
+ {name}
+ ) } diff --git a/themes/heo/components/Hero.js b/themes/heo/components/Hero.js index 656bca55950..b43987e67d0 100644 --- a/themes/heo/components/Hero.js +++ b/themes/heo/components/Hero.js @@ -2,6 +2,7 @@ import { ArrowSmallRight, PlusSmall } from '@/components/HeroIcons' import LazyImage from '@/components/LazyImage' import { siteConfig } from '@/lib/config' +import { useGlobal } from '@/lib/global' import Link from 'next/link' import { useRouter } from 'next/router' import { useImperativeHandle, useRef, useState } from 'react' @@ -206,6 +207,7 @@ function GroupMenu() { */ function TopGroup(props) { const { latestPosts, allNavPages, siteInfo } = props + const { locale } = useGlobal() const todayCardRef = useRef() function handleMouseLeave() { todayCardRef.current.coverUp() @@ -238,7 +240,7 @@ function TopGroup(props) {
{/* hover 悬浮的 ‘荐’ 字 */}
- 荐 + {locale.COMMON.RECOMMEND_BADGES}
@@ -304,6 +306,7 @@ function getTopPosts({ latestPosts, allNavPages }) { function TodayCard({ cRef, siteInfo }) { const router = useRouter() const link = siteConfig('HEO_HERO_TITLE_LINK', null, CONFIG) + const { locale } = useGlobal() // 卡牌是否盖住下层 const [isCoverUp, setIsCoverUp] = useState(true) @@ -348,7 +351,7 @@ function TodayCard({ cRef, siteInfo }) { isCoverUp ? 'opacity-100 cursor-pointer' : 'opacity-0 transform scale-110 pointer-events-none' - } shadow transition-all duration-200 today-card h-full bg-[#0E57D5] rounded-xl relative overflow-hidden flex items-end`}> + } shadow transition-all duration-200 today-card h-full bg-[#0E57D5] dark:bg-yellow-500 rounded-xl relative overflow-hidden flex items-end`}>
@@ -364,12 +367,14 @@ function TodayCard({ cRef, siteInfo }) { onClick={handleClickMore} className={`'${ isCoverUp ? '' : 'hidden pointer-events-none ' - } flex items-center px-3 h-10 justify-center bg-[#425aef] hover:bg-[#4259efcb] transition-colors duration-100 rounded-3xl`}> + } flex items-center px-3 h-10 justify-center bg-[#425aef] hover:bg-[#4259efcb] dark:bg-yellow-500 dark:hover:bg-yellow-600 transition-colors duration-100 rounded-3xl`}>
- 更多推荐 + {locale.COMMON.MORE}
diff --git a/themes/heo/components/LatestPostsGroupMini.js b/themes/heo/components/LatestPostsGroupMini.js index 7bc65df3a5f..c8f0dcf4ef9 100644 --- a/themes/heo/components/LatestPostsGroupMini.js +++ b/themes/heo/components/LatestPostsGroupMini.js @@ -50,13 +50,13 @@ export default function LatestPostsGroupMini({ latestPosts, siteInfo }) {
{post.title}
-
{post.lastEditedDay}
+
{post.lastEditedDay}
diff --git a/themes/heo/components/MenuItemCollapse.js b/themes/heo/components/MenuItemCollapse.js index f0f9486b769..6278cebe346 100644 --- a/themes/heo/components/MenuItemCollapse.js +++ b/themes/heo/components/MenuItemCollapse.js @@ -28,7 +28,7 @@ export const MenuItemCollapse = ({ link }) => { return ( <>
{!hasSubMenu && ( { return (
+ className='dark:bg-hexo-black-gray dark:text-gray-200 text-left px-3 justify-start bg-gray-50 hover:bg-gray-50 dark:hover:bg-gray-900 tracking-widest transition-all duration-200 py-3 pr-6'> {link?.icon && }{' '} diff --git a/themes/heo/components/MenuItemDrop.js b/themes/heo/components/MenuItemDrop.js index 2e6929a7e34..4f8241fc131 100644 --- a/themes/heo/components/MenuItemDrop.js +++ b/themes/heo/components/MenuItemDrop.js @@ -36,12 +36,12 @@ export const MenuItemDrop = ({ link }) => { {hasSubMenu && (
    + className={`${show ? 'visible opacity-100 top-14' : 'invisible opacity-0 top-20'} drop-shadow-md overflow-hidden rounded-xl bg-white dark:bg-[#1e1e1e] border dark:border-gray-700 transition-all duration-300 z-20 absolute`}> {link.subMenus.map((sLink, index) => { return (
  • + className='cursor-pointer hover:bg-blue-600 dark:hover:bg-yellow-600 hover:text-white text-gray-900 dark:text-gray-100 tracking-widest transition-all duration-200 dark:border-gray-700 py-1 pr-6 pl-3'> {link?.icon &&   } diff --git a/themes/heo/components/MenuListSide.js b/themes/heo/components/MenuListSide.js index 5716d5b8be7..50bec3c2499 100644 --- a/themes/heo/components/MenuListSide.js +++ b/themes/heo/components/MenuListSide.js @@ -48,7 +48,7 @@ export const MenuListSide = props => { } return ( -