feat(web): 前端共享基础(focusRing/proseBody/text-2xs + useBodyScrollLock + Toast撤销 + error/not-found/loading路由边界)

This commit is contained in:
Yaojia Wang
2026-06-30 08:35:52 +02:00
parent 69f3c2a29b
commit a22a16c9c4
9 changed files with 245 additions and 23 deletions

View File

@@ -0,0 +1,20 @@
"use client";
import { useEffect } from "react";
// 弹层Drawer / CommandPalette / Modal打开时锁定 body 滚动,关闭后恢复原值。
// SSR 守卫:服务端无 document直接跳过。
export function useBodyScrollLock(active: boolean): void {
useEffect(() => {
if (!active) return;
if (typeof document === "undefined") return;
const { body } = document;
const previousOverflow = body.style.overflow;
body.style.overflow = "hidden";
return () => {
body.style.overflow = previousOverflow;
};
}, [active]);
}