单应用项目,可以创建很多独立工具类页面 ,不用登录 初始化的页面
zhangchen
2025-07-08 4981c1f1ef22523cb2dc027c7c8126dfb924c5af
1
2
3
4
5
6
7
8
9
10
11
/**
 * 计算某个类名元素的可用高度(视口高度 - 元素顶部距离)
 * @param className 元素类名(不带.)
 * @returns 可用高度(px),找不到元素则返回 0
 */
export function getAvailableHeightByClass(className: string): number {
  const el = document.querySelector(`.${className}`) as HTMLElement | null
  if (!el) return 0
  const rect = el.getBoundingClientRect()
  return window.innerHeight - rect.top
}