From dc7e53343cfeb18cd8f49ca0f0afb0cc6ebea521 Mon Sep 17 00:00:00 2001 From: "tangly1024.com" Date: Mon, 3 Jun 2024 18:47:52 +0800 Subject: [PATCH] =?UTF-8?q?fukasawa=20=E4=B8=80=E7=82=B9=E5=BE=AE=E8=B0=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- themes/fukasawa/components/AsideLeft.js | 205 ++++++++++++--------- themes/fukasawa/components/Header.js | 64 +++++++ themes/fukasawa/components/TopNav.js | 50 ----- themes/fukasawa/index.js | 233 ++++++++++++++---------- 4 files changed, 320 insertions(+), 232 deletions(-) create mode 100644 themes/fukasawa/components/Header.js delete mode 100644 themes/fukasawa/components/TopNav.js diff --git a/themes/fukasawa/components/AsideLeft.js b/themes/fukasawa/components/AsideLeft.js index f534d1b6..b0ea2313 100644 --- a/themes/fukasawa/components/AsideLeft.js +++ b/themes/fukasawa/components/AsideLeft.js @@ -1,22 +1,22 @@ -import Logo from './Logo' -import GroupCategory from './GroupCategory' -import { MenuList } from './MenuList' -import GroupTag from './GroupTag' -import SearchInput from './SearchInput' -import SiteInfo from './SiteInfo' -import Catalog from './Catalog' -import Announcement from './Announcement' -import { useRouter } from 'next/router' import DarkModeButton from '@/components/DarkModeButton' -import SocialButton from './SocialButton' -import CONFIG from '@/themes/fukasawa/config' import { AdSlot } from '@/components/GoogleAdsense' import { siteConfig } from '@/lib/config' -import MailChimpForm from './MailChimpForm' import { useGlobal } from '@/lib/global' -import { useEffect, useMemo, useState } from 'react' import { isBrowser } from '@/lib/utils' +import CONFIG from '@/themes/fukasawa/config' import { debounce } from 'lodash' +import { useRouter } from 'next/router' +import { useEffect, useMemo, useState } from 'react' +import Announcement from './Announcement' +import Catalog from './Catalog' +import GroupCategory from './GroupCategory' +import GroupTag from './GroupTag' +import Logo from './Logo' +import MailChimpForm from './MailChimpForm' +import { MenuList } from './MenuList' +import SearchInput from './SearchInput' +import SiteInfo from './SiteInfo' +import SocialButton from './SocialButton' /** * 侧边栏 @@ -24,16 +24,41 @@ import { debounce } from 'lodash' * @returns */ function AsideLeft(props) { - const { tagOptions, currentTag, categoryOptions, currentCategory, post, slot, notice } = props + const { + tagOptions, + currentTag, + categoryOptions, + currentCategory, + post, + slot, + notice + } = props const router = useRouter() const { fullWidth } = useGlobal() - const FUKASAWA_SIDEBAR_COLLAPSE_SATUS_DEFAULT = fullWidth || siteConfig('FUKASAWA_SIDEBAR_COLLAPSE_SATUS_DEFAULT', null, CONFIG) + const FUKASAWA_SIDEBAR_COLLAPSE_SATUS_DEFAULT = + fullWidth || + siteConfig('FUKASAWA_SIDEBAR_COLLAPSE_SATUS_DEFAULT', null, CONFIG) + + const FUKASAWA_SIDEBAR_COLLAPSE_ON_SCROLL = siteConfig( + 'FUKASAWA_SIDEBAR_COLLAPSE_ON_SCROLL', + false, + CONFIG + ) + + const FUKASAWA_SIDEBAR_COLLAPSE_BUTTON = siteConfig( + 'FUKASAWA_SIDEBAR_COLLAPSE_BUTTON', + null, + CONFIG + ) // 侧边栏折叠从 本地存储中获取 open 状态的初始值 const [isCollapsed, setIsCollapse] = useState(() => { if (typeof window !== 'undefined') { - return localStorage.getItem('fukasawa-sidebar-collapse') === 'true' || FUKASAWA_SIDEBAR_COLLAPSE_SATUS_DEFAULT + return ( + localStorage.getItem('fukasawa-sidebar-collapse') === 'true' || + FUKASAWA_SIDEBAR_COLLAPSE_SATUS_DEFAULT + ) } return FUKASAWA_SIDEBAR_COLLAPSE_SATUS_DEFAULT }) @@ -69,7 +94,7 @@ function AsideLeft(props) { // 自动折叠侧边栏 onResize 窗口宽度小于1366 || 滚动条滚动至页面的300px时 ; 将open设置为false useEffect(() => { - if (!siteConfig('FUKASAWA_SIDEBAR_COLLAPSE_ON_SCROLL', false, CONFIG)) { + if (!FUKASAWA_SIDEBAR_COLLAPSE_ON_SCROLL) { return } const handleResize = debounce(() => { @@ -92,73 +117,89 @@ function AsideLeft(props) { } } }, []) - - - return