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() {
|
||||
if (process.platform !== "darwin") {
|
||||
return;
|
||||
}
|
||||
|
||||
ApplicationMenu.setApplicationMenu(buildApplicationMenuTemplate());
|
||||
}
|
||||
|
||||
@ -150,6 +154,10 @@ export function setupApplicationMenuEvents({
|
||||
onToggleDevTools,
|
||||
onCheckForUpdates,
|
||||
}) {
|
||||
if (process.platform !== "darwin") {
|
||||
return;
|
||||
}
|
||||
|
||||
navigateHandler = onNavigate;
|
||||
|
||||
ApplicationMenu.on("application-menu-clicked", (event) => {
|
||||
|
||||
@ -261,16 +261,19 @@ export async function createMainWindow(rpc) {
|
||||
}
|
||||
|
||||
setupMainWindowMessaging(mainWindow)
|
||||
applyApplicationMenu()
|
||||
setupApplicationMenuEvents({
|
||||
onNavigate: sendNavigateToRenderer,
|
||||
onToggleDevTools: () => {
|
||||
mainWindow?.webview?.toggleDevTools?.()
|
||||
},
|
||||
onCheckForUpdates: () => {
|
||||
sendToRenderer('checkForUpdates')
|
||||
}
|
||||
})
|
||||
|
||||
if (isMacOS) {
|
||||
applyApplicationMenu()
|
||||
setupApplicationMenuEvents({
|
||||
onNavigate: sendNavigateToRenderer,
|
||||
onToggleDevTools: () => {
|
||||
mainWindow?.webview?.toggleDevTools?.()
|
||||
},
|
||||
onCheckForUpdates: () => {
|
||||
sendToRenderer('checkForUpdates')
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
setupWindowEvents(mainWindow)
|
||||
applyStartupWindowState(mainWindow)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user