From dd0ba7a99fbf73b35f958604e2db028b74541e8e Mon Sep 17 00:00:00 2001 From: cvpv Date: Tue, 11 Nov 2025 21:22:44 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=20usePageHeight=20ho?= =?UTF-8?q?ok=20=E8=A7=A3=E5=86=B3=E5=BD=93=E6=97=A0=E6=B3=95=E7=BA=A6?= =?UTF-8?q?=E6=9D=9F=E5=AD=90=E5=85=83=E7=B4=A0=E6=BA=A2=E5=87=BA=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/layout/hooks/usePageHeight.ts | 38 +++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 src/layout/hooks/usePageHeight.ts diff --git a/src/layout/hooks/usePageHeight.ts b/src/layout/hooks/usePageHeight.ts new file mode 100644 index 0000000000..d8c955ca7a --- /dev/null +++ b/src/layout/hooks/usePageHeight.ts @@ -0,0 +1,38 @@ +import { computed } from "vue"; + +import { useGlobal } from "@pureadmin/utils"; +import { useTags } from "@/layout/hooks/useTag"; + +const NAVBAR_HEIGHT = 48; // 顶部导航栏高度 +const TAGS_HEIGHT_CHROME = 38; // Chrome 模式标签页高度 +const TAGS_HEIGHT_DEFAULT = 34; // 默认标签页高度 +const FOOTER_HEIGHT = 32; // 页脚高度 + +/** + * 获取当前页面内容区的可用高度 + */ +export function usePageHeight() { + const { $storage } = useGlobal(); + const { showModel } = useTags(); + + const hideTabs = computed(() => $storage?.configure.hideTabs); + const hideFooter = computed(() => $storage?.configure.hideFooter); + + const tagsHeight = computed(() => { + if (hideTabs.value) return 0; + return showModel.value === "chrome" + ? TAGS_HEIGHT_CHROME + : TAGS_HEIGHT_DEFAULT; + }); + + const footerHeight = computed(() => { + return hideFooter.value ? 0 : FOOTER_HEIGHT; + }); + + const pageHeight = computed(() => { + const offset = NAVBAR_HEIGHT + tagsHeight.value + footerHeight.value; + return `calc(100vh - ${offset}px)`; + }); + + return pageHeight; +}