feat: chat panel UE done

This commit is contained in:
butterfly
2024-04-18 12:27:44 +08:00
parent 51a1d9f92a
commit b3559f99a2
39 changed files with 953 additions and 447 deletions

View File

@@ -1,4 +1,4 @@
import { useLayoutEffect, useMemo, useRef } from "react";
import { useLayoutEffect, useRef } from "react";
type Size = {
width: number;
@@ -7,15 +7,6 @@ type Size = {
export function useWindowSize(callback: (size: Size) => void) {
const callbackRef = useRef<typeof callback>();
const hascalled = useRef(false);
if (typeof window !== "undefined" && !hascalled.current) {
callback({
width: window.innerWidth,
height: window.innerHeight,
});
hascalled.current = true;
}
callbackRef.current = callback;
@@ -29,6 +20,11 @@ export function useWindowSize(callback: (size: Size) => void) {
window.addEventListener("resize", onResize);
callback({
width: window.innerWidth,
height: window.innerHeight,
});
return () => {
window.removeEventListener("resize", onResize);
};