优化Page

master
LiuJiaNan 2025-12-26 13:50:59 +08:00
parent 45bcba0f77
commit 57f0801d6b
1 changed files with 25 additions and 20 deletions

View File

@ -32,36 +32,41 @@ function Page(props) {
const timer = setTimeout(() => {
getPageWidth();
}, 0);
window.addEventListener("resize", getPageWidth);
if (isShowAllAction && isShowFooter) {
window.addEventListener("resize", getPageWidth);
}
return () => {
window.removeEventListener("resize", getPageWidth);
if (isShowAllAction && isShowFooter) {
window.removeEventListener("resize", getPageWidth);
}
clearTimeout(timer);
};
}, []);
}, [isShowAllAction, isShowFooter]);
return (
<div className="page" id="page">
{(isShowAllAction && isShowHeader) && <HeaderBack title={headerTitle} history={history} previous={headerPrevious} />}
<div style={{ padding: contentPadding }}>
{props.children}
{
(isShowAllAction && isShowFooter) && (
<>
<div style={{ height: "52px" }}></div>
<div style={{ textAlign: "center", backgroundColor: "rgb(241, 241, 242)", padding: "10px 0", position: "fixed", bottom: "0", width: pageWidth, margin: "0px -20px" }}>
{customActionButtons || (
<Space>
{extraActionButtons}
<Button onClick={() => history?.goBack?.() || window.history.back()}>
{backButtonText}
</Button>
</Space>
)}
</div>
</>
)
}
</div>
{
(isShowAllAction && isShowFooter) && (
<>
<div style={{ height: "32px" }}></div>
<div style={{ textAlign: "center", backgroundColor: "rgb(241, 241, 242)", padding: "10px 0", position: "fixed", bottom: "0", width: pageWidth, margin: "0px -44px" }}>
{customActionButtons || (
<Space>
{extraActionButtons}
<Button onClick={() => history?.goBack?.() || window.history.back()}>
{backButtonText}
</Button>
</Space>
)}
</div>
</>
)
}
</div>
);
}