From 1d73dc6de16239b88a192a9b309b3da0750ad3e2 Mon Sep 17 00:00:00 2001 From: tangly1024 Date: Wed, 13 Oct 2021 12:41:16 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AF=BC=E8=88=AA=E6=9D=A1=E5=8A=A0=E9=98=B4?= =?UTF-8?q?=E5=BD=B1=EF=BC=9B=20=E8=88=AA=E6=9D=A1=E6=A0=87=E7=AD=BE?= =?UTF-8?q?=E6=A0=8F=E6=BB=9A=E5=8A=A8=E6=97=B6=E9=9A=90=E8=97=8F=EF=BC=9B?= =?UTF-8?q?=20=E4=BD=BF=E7=94=A8Container=E5=AE=B9=E5=99=A8;=20=E7=A7=BB?= =?UTF-8?q?=E5=8A=A8=E7=AB=AF=E6=96=87=E7=AB=A0=E8=BE=B9=E8=B7=9D=E8=B0=83?= =?UTF-8?q?=E6=95=B4=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/CommonHead.js | 1 + components/Drawer.js | 37 ++++++++++++++++++++--------------- components/MenuButtonGroup.js | 4 ++-- components/SideBar.js | 2 +- components/TocBar.js | 2 +- components/TopNav.js | 27 ++++++++++++++++--------- layouts/ArticleLayout.js | 14 +++++-------- layouts/DefaultLayout.js | 13 ++++++------ 8 files changed, 55 insertions(+), 45 deletions(-) diff --git a/components/CommonHead.js b/components/CommonHead.js index cdc12b36..aef00a8e 100644 --- a/components/CommonHead.js +++ b/components/CommonHead.js @@ -1,5 +1,6 @@ import BLOG from '@/blog.config' import Head from 'next/head' +import ThirdPartyScript from '@/components/ThirdPartyScript' const CommonHead = ({ meta }) => { const url = BLOG.path.length ? `${BLOG.link}/${BLOG.path}` : BLOG.link diff --git a/components/Drawer.js b/components/Drawer.js index 7a670907..6f98a6f2 100644 --- a/components/Drawer.js +++ b/components/Drawer.js @@ -3,32 +3,35 @@ import BLOG from '@/blog.config' import SearchInput from '@/components/SearchInput' import MenuButtonGroup from '@/components/MenuButtonGroup' import TocBar from '@/components/TocBar' -import React, { useState } from 'react' +import React, { forwardRef, useImperativeHandle, useState } from 'react' /** * 抽屉面板,可以从侧面拉出 * @returns {JSX.Element} * @constructor */ -const Drawer = ({ post, currentTag }) => { +const Drawer = ({ post, currentTag, cRef }) => { + // 暴露给父组件 通过cRef.current.handleMenuClick 调用 + useImperativeHandle(cRef, () => { + return { + handleMenuClick: () => handleMenuClick() + } + }) const [showDrawer, switchShowDrawer] = useState(false) // 点击按钮更改侧边抽屉状态 const handleMenuClick = () => { switchShowDrawer(!showDrawer) } return
- {/* 触发抽屉按钮 */} -
- -
-
+
{/* LOGO */} -
-
- +
+
+
{
{/* 侧边菜单 */} -
+
- +
{/* 菜单 */} - + {post && (
@@ -56,7 +60,8 @@ const Drawer = ({ post, currentTag }) => {
{/* 背景蒙版 */} -
+
} export default Drawer diff --git a/components/MenuButtonGroup.js b/components/MenuButtonGroup.js index d7ef8d8e..5b9b2d70 100644 --- a/components/MenuButtonGroup.js +++ b/components/MenuButtonGroup.js @@ -23,14 +23,14 @@ const MenuButtonGroup = ({ allowCollapse = false }) => { link.show && (
  • -
    {link.name}
    +
    {link.name}
  • ) diff --git a/components/SideBar.js b/components/SideBar.js index 0b022054..21264289 100644 --- a/components/SideBar.js +++ b/components/SideBar.js @@ -3,7 +3,7 @@ import TocBar from '@/components/TocBar' import MenuButtonGroup from '@/components/MenuButtonGroup' const SideBar = ({ tags, currentTag, post }) => { - return