fix: menubar window width height wrong

This commit is contained in:
linonetwo 2024-02-04 12:53:55 +08:00
parent 8480d576ef
commit 660c40539f
2 changed files with 10 additions and 4 deletions

View file

@ -47,8 +47,14 @@ export async function handleAttachToMenuBar(windowConfig: BrowserWindowConstruct
if (menuBar.window === undefined) {
logger.debug('menuBar.window is undefined');
} else {
menuBar.window.setPosition(windowWithBrowserViewState.x, windowWithBrowserViewState.y, false);
menuBar.window.setSize(windowWithBrowserViewState.width, windowWithBrowserViewState.height, false);
const haveXYValue = [windowWithBrowserViewState.x, windowWithBrowserViewState.y].every((value) => Number.isFinite(value));
const haveWHValue = [windowWithBrowserViewState.width, windowWithBrowserViewState.height].every((value) => Number.isFinite(value));
if (haveXYValue) {
menuBar.window.setPosition(windowWithBrowserViewState.x, windowWithBrowserViewState.y, false);
}
if (haveWHValue) {
menuBar.window.setSize(windowWithBrowserViewState.width, windowWithBrowserViewState.height, false);
}
}
}
const view = menuBar.window?.getBrowserView();