fix: #730 icon not change when the window is opened maximized (#924)

Co-authored-by: tyliu9 <tyliu9@toycloud.com>
This commit is contained in:
LiuTianYu 2024-04-24 22:36:15 +08:00 committed by GitHub
parent 6c7afd168a
commit 0e82426ea1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -8,18 +8,29 @@ import {
PushPinOutlined, PushPinOutlined,
PushPinRounded, PushPinRounded,
} from "@mui/icons-material"; } from "@mui/icons-material";
import { useState } from "react"; import { useEffect, useState } from "react";
export const LayoutControl = () => { export const LayoutControl = () => {
const minWidth = 40; const minWidth = 40;
const [isMaximized, setIsMaximized] = useState(false); const [isMaximized, setIsMaximized] = useState(false);
const [isPined, setIsPined] = useState(false); const [isPined, setIsPined] = useState(false);
appWindow.onResized(() => {
appWindow.isMaximized().then((isMaximized) => { useEffect(() => {
setIsMaximized(() => isMaximized); const unlistenResized = appWindow.onResized(() => {
appWindow.isMaximized().then((maximized) => {
setIsMaximized(() => maximized);
});
}); });
});
appWindow.isMaximized().then((maximized) => {
setIsMaximized(() => maximized);
});
return () => {
unlistenResized.then((fn) => fn());
};
}, []);
return ( return (
<ButtonGroup <ButtonGroup