Files
WAI_Project_UNIX/cool/utils/rect.ts

69 lines
1.2 KiB
TypeScript
Raw Normal View History

2025-08-11 19:14:03 +08:00
import { config } from "@/config";
import { router } from "../router";
import { isH5, isHarmony } from "./comm";
import { ctx } from "../ctx";
import { getPx } from "./parse";
/**
* tabBar
* @returns boolean
*/
export function hasCustomTabBar() {
if (router.isTabPage()) {
if (isHarmony()) {
return false;
}
return config.isCustomTabBar || isH5();
}
return false;
}
/**
* topbar
* @returns boolean
*/
export function hasCustomTopbar() {
return router.route()?.isCustomNavbar ?? false;
}
/**
*
* @param type
* @returns
*/
export function getSafeAreaHeight(type: "top" | "bottom") {
const { safeAreaInsets } = uni.getWindowInfo();
let h: number;
if (type == "top") {
h = safeAreaInsets.top;
} else {
h = safeAreaInsets.bottom;
// #ifdef APP-ANDROID
if (h == 0) {
h = 16;
}
// #endif
}
return h;
}
/**
* tabBar
* @returns tabBar
*/
export function getTabBarHeight() {
let h = ctx.tabBar.height == null ? 50 : getPx(ctx.tabBar.height!);
if (hasCustomTabBar()) {
h += getSafeAreaHeight("bottom");
}
return h;
}