From e92ff396588126d05735f973c38235daec905c5e Mon Sep 17 00:00:00 2001 From: Vomitblood Date: Sun, 10 Nov 2024 21:51:27 +0800 Subject: [PATCH] fixed headerbar --- client/bun.lockb | Bin 172070 -> 172070 bytes client/src-tauri/tauri.conf.json | 17 +++++- .../components/HeaderBar/WindowButtons.tsx | 57 +++--------------- 3 files changed, 24 insertions(+), 50 deletions(-) diff --git a/client/bun.lockb b/client/bun.lockb index d1ee4e43b344baaf7a2d72619c87ca668a6ab176..45b9bab797a318e45e5148871116f80868eb4555 100755 GIT binary patch delta 25 hcmZ2>fNR+Su7)j)b9b{d#u@1u>KSZbvYWB#2>^zc3P1n= delta 25 ecmZ2>fNR+Su7)j)b9b{dF@VALCA%4$o&W%O& { // contexts const userTheme = useTheme(); - // states - const [appWindow, setAppWindow] = useState(); - - // explanation: - // this is needed due to the server-sided nature of next js, - // this means that the window object might not be available on first load - // we will use dynamic imports to load the window object only when needed - // in hindsight, using next js for this project was a mistake - // using create-react-app or vite would have been a better choice just to generate a static site - const initializeAppWindow = async () => { - setAppWindow(getCurrentWebviewWindow()); - }; - - const toggleFullscreen = async () => { - appWindow?.setFullscreen(!(await appWindow?.isFullscreen())); - }; - const minimize = () => { - appWindow?.minimize(); + const appWindow = getCurrentWindow(); + appWindow.minimize(); }; const toggleMaximize = () => { - appWindow?.toggleMaximize(); + const appWindow = getCurrentWindow(); + appWindow.toggleMaximize(); }; const close = async () => { - appWindow?.close(); + const appWindow = getCurrentWindow(); + appWindow.close(); }; - useEffect(() => { - initializeAppWindow(); - }); - return ( { }} > - - {appWindow?.isFullscreen() ? ( - - ) : ( - - )} -