mirror of
https://github.com/Yidadaa/ChatGPT-Next-Web.git
synced 2025-10-23 00:19:23 +08:00
feat: chat panel UE done
This commit is contained in:
@@ -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);
|
||||
};
|
||||
|
Reference in New Issue
Block a user