diff --git a/src/components/Page/index.js b/src/components/Page/index.js index 05a7a0b..eae666d 100644 --- a/src/components/Page/index.js +++ b/src/components/Page/index.js @@ -1,5 +1,6 @@ import { Button, Space } from "antd"; import { useEffect, useState } from "react"; +import { throttle } from "throttle-debounce"; import HeaderBack from "../HeaderBack"; /** @@ -21,12 +22,12 @@ function Page(props) { const [pageWidth, setPageWidth] = useState(window.innerWidth); - const getPageWidth = () => { - const pageDom = document.querySelector("#page"); + const getPageWidth = throttle(50, () => { + const pageDom = document.querySelector("#page-layout"); if (!pageDom) return; setPageWidth(pageDom.offsetWidth); - }; + }); useEffect(() => { const timer = setTimeout(() => { @@ -45,13 +46,13 @@ function Page(props) { }, [isShowAllAction, isShowFooter]); return ( -
+
{(isShowAllAction && isShowHeader) && }
{props.children} { (isShowAllAction && isShowFooter) && ( - <> +
{customActionButtons || ( @@ -63,7 +64,7 @@ function Page(props) { )}
- +
) }