单应用项目,可以创建很多独立工具类页面 ,不用登录 初始化的页面
zhangchen
2025-07-09 6c0b8c25d8c523c3f800aaae59362abef7fd1906
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
}