Restrict application menu functionality to macOS
All checks were successful
farmcontrol/farmcontrol-ui/pipeline/head This commit looks good
All checks were successful
farmcontrol/farmcontrol-ui/pipeline/head This commit looks good
- Updated `applyApplicationMenu` and `setupApplicationMenuEvents` functions to return early if the platform is not macOS, ensuring that menu features are only available on macOS. - Adjusted the `createMainWindow` function to conditionally call menu setup functions based on the operating system, improving cross-platform compatibility.
This commit is contained in:
parent
d2d64ef45d
commit
ddaeb3cfff
@ -132,6 +132,10 @@ function buildApplicationMenuTemplate() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function applyApplicationMenu() {
|
export function applyApplicationMenu() {
|
||||||
|
if (process.platform !== "darwin") {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
ApplicationMenu.setApplicationMenu(buildApplicationMenuTemplate());
|
ApplicationMenu.setApplicationMenu(buildApplicationMenuTemplate());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -150,6 +154,10 @@ export function setupApplicationMenuEvents({
|
|||||||
onToggleDevTools,
|
onToggleDevTools,
|
||||||
onCheckForUpdates,
|
onCheckForUpdates,
|
||||||
}) {
|
}) {
|
||||||
|
if (process.platform !== "darwin") {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
navigateHandler = onNavigate;
|
navigateHandler = onNavigate;
|
||||||
|
|
||||||
ApplicationMenu.on("application-menu-clicked", (event) => {
|
ApplicationMenu.on("application-menu-clicked", (event) => {
|
||||||
|
|||||||
@ -261,6 +261,8 @@ export async function createMainWindow(rpc) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
setupMainWindowMessaging(mainWindow)
|
setupMainWindowMessaging(mainWindow)
|
||||||
|
|
||||||
|
if (isMacOS) {
|
||||||
applyApplicationMenu()
|
applyApplicationMenu()
|
||||||
setupApplicationMenuEvents({
|
setupApplicationMenuEvents({
|
||||||
onNavigate: sendNavigateToRenderer,
|
onNavigate: sendNavigateToRenderer,
|
||||||
@ -271,6 +273,7 @@ export async function createMainWindow(rpc) {
|
|||||||
sendToRenderer('checkForUpdates')
|
sendToRenderer('checkForUpdates')
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
}
|
||||||
|
|
||||||
setupWindowEvents(mainWindow)
|
setupWindowEvents(mainWindow)
|
||||||
applyStartupWindowState(mainWindow)
|
applyStartupWindowState(mainWindow)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user