From 4e46e5e5ea566f6aab9642dbea71548449dd939c Mon Sep 17 00:00:00 2001 From: LiuJiaNan <15703339975@163.com> Date: Fri, 26 Dec 2025 11:49:46 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96Page?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Page/index.js | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/src/components/Page/index.js b/src/components/Page/index.js index be6e024..2e38a62 100644 --- a/src/components/Page/index.js +++ b/src/components/Page/index.js @@ -1,4 +1,5 @@ import { Button, Space } from "antd"; +import { useEffect, useState } from "react"; import HeaderBack from "../HeaderBack"; /** @@ -18,17 +19,37 @@ function Page(props) { extraActionButtons, } = props; + const [pageWidth, setPageWidth] = useState(window.innerWidth); + + const getPageWidth = () => { + const pageDom = document.querySelector("#page"); + if (!pageDom) + return; + setPageWidth(pageDom.offsetWidth); + }; + + useEffect(() => { + const timer = setTimeout(() => { + getPageWidth(); + }, 0); + window.addEventListener("resize", getPageWidth); + return () => { + window.removeEventListener("resize", getPageWidth); + clearTimeout(timer); + }; + }, []); + return ( -
+
{(isShowAllAction && isShowHeader) && }
{props.children}
{ (isShowAllAction && isShowFooter) && ( -
-
-
+ <> +
+
{customActionButtons || ( {extraActionButtons} @@ -38,7 +59,7 @@ function Page(props) { )}
-
+ ) }