From c2d932402ca6c6cc257f4ff79fd83adae705a35b Mon Sep 17 00:00:00 2001 From: "tangly1024.com" Date: Fri, 8 Nov 2024 18:38:57 +0800 Subject: [PATCH] =?UTF-8?q?starter=E4=B8=BB=E9=A2=98logo=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- themes/starter/components/Header.js | 4 ++-- themes/starter/components/Logo.js | 14 +++++++++----- themes/starter/index.js | 3 ++- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/themes/starter/components/Header.js b/themes/starter/components/Header.js index e8f0c7f24b6..ef69c077a69 100644 --- a/themes/starter/components/Header.js +++ b/themes/starter/components/Header.js @@ -33,7 +33,7 @@ export const Header = props => { return () => { window.removeEventListener('scroll', navBarScollListener) } - }, [[isDarkMode]]) + }, [isDarkMode]) // 滚动监听 const throttleMs = 200 @@ -58,7 +58,7 @@ export const Header = props => {
{/* Logo */} - +
{/* 中间菜单 */} diff --git a/themes/starter/components/Logo.js b/themes/starter/components/Logo.js index e290d4d9948..c73cd4ceef6 100644 --- a/themes/starter/components/Logo.js +++ b/themes/starter/components/Logo.js @@ -10,10 +10,12 @@ import { useEffect, useState } from 'react' * 站点图标 * @returns */ -export const Logo = ({ white }) => { +export const Logo = props => { + const { white, NOTION_CONFIG } = props const router = useRouter() - const { isDarkMode } = useGlobal() const logoWhite = siteConfig('STARTER_LOGO_WHITE') + const logoNormal = siteConfig('STARTER_LOGO') + const { isDarkMode } = useGlobal() const [logo, setLogo] = useState(logoWhite) const [logoTextColor, setLogoTextColor] = useState('text-white') @@ -24,11 +26,12 @@ export const Logo = ({ white }) => { const scrollY = window.scrollY // 何时显示浅色或白底的logo const homePageNavBar = router.route === '/' && scrollY < 10 // 在首页并且视窗在页面顶部 + if (white || isDarkMode || homePageNavBar) { - setLogo(siteConfig('STARTER_LOGO_WHITE')) + setLogo(logoWhite) setLogoTextColor('text-white') } else { - setLogo(siteConfig('STARTER_LOGO')) + setLogo(logoNormal) setLogoTextColor('text-black') } }, throttleMs) @@ -50,8 +53,9 @@ export const Logo = ({ white }) => { router.push('/') }} src={logo} + height={14} alt='logo' - className='header-logo w-full' + className='header-logo w-full mr-1' /> )} {/* logo文字 */} diff --git a/themes/starter/index.js b/themes/starter/index.js index da034ac5f19..35d837bd559 100644 --- a/themes/starter/index.js +++ b/themes/starter/index.js @@ -81,6 +81,7 @@ const LayoutBase = props => { */ const LayoutIndex = props => { const count = siteConfig('STARTER_BLOG_COUNT', 3, CONFIG) + const { locale } = useGlobal() const posts = props?.allNavPages ? props.allNavPages.slice(0, count) : [] return ( <> @@ -108,7 +109,7 @@ const LayoutIndex = props => {
- 查看全部 + {locale.COMMON.MORE}