Add application menu structure for macOS and Windows
- Implemented functions to build application menus for macOS, including 'About', 'Edit', 'File', and 'Window' menus. - Enhanced the application menu template to include these new menu structures, improving user navigation and functionality. - Ensured compatibility with macOS by conditionally adding the app menu based on the platform.
This commit is contained in:
parent
40ccacc9a8
commit
3b28aa4308
@ -5,6 +5,63 @@ const SIDEBAR_MENU_ACTION_PREFIX = "sidebar-nav:";
|
|||||||
let sidebarViewMenuSections = [];
|
let sidebarViewMenuSections = [];
|
||||||
let navigateHandler = null;
|
let navigateHandler = null;
|
||||||
|
|
||||||
|
function buildMacAppMenu() {
|
||||||
|
return {
|
||||||
|
submenu: [
|
||||||
|
{
|
||||||
|
label: "About Farm Control",
|
||||||
|
action: `${SIDEBAR_MENU_ACTION_PREFIX}/dashboard/management/about`,
|
||||||
|
},
|
||||||
|
{ type: "separator" },
|
||||||
|
{ role: "hide" },
|
||||||
|
{ role: "hideOthers" },
|
||||||
|
{ role: "showAll" },
|
||||||
|
{ type: "separator" },
|
||||||
|
{ role: "quit" },
|
||||||
|
],
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
function buildEditMenu() {
|
||||||
|
return {
|
||||||
|
label: "Edit",
|
||||||
|
submenu: [
|
||||||
|
{ role: "undo" },
|
||||||
|
{ role: "redo" },
|
||||||
|
{ type: "separator" },
|
||||||
|
{ role: "cut" },
|
||||||
|
{ role: "copy" },
|
||||||
|
{ role: "paste" },
|
||||||
|
{ role: "pasteAndMatchStyle" },
|
||||||
|
{ role: "delete" },
|
||||||
|
{ type: "separator" },
|
||||||
|
{ role: "selectAll" },
|
||||||
|
{ type: "separator" },
|
||||||
|
{ role: "startSpeaking" },
|
||||||
|
{ role: "stopSpeaking" },
|
||||||
|
],
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
function buildFileMenu() {
|
||||||
|
return {
|
||||||
|
label: "File",
|
||||||
|
submenu: [{ role: "close" }],
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
function buildWindowMenu() {
|
||||||
|
return {
|
||||||
|
label: "Window",
|
||||||
|
submenu: [
|
||||||
|
{ role: "minimize" },
|
||||||
|
{ role: "zoom" },
|
||||||
|
{ type: "separator" },
|
||||||
|
{ role: "bringAllToFront" },
|
||||||
|
],
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
function toMenuItems(items = []) {
|
function toMenuItems(items = []) {
|
||||||
return items
|
return items
|
||||||
.map((item) => {
|
.map((item) => {
|
||||||
@ -56,14 +113,14 @@ function buildApplicationMenuTemplate() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const template = [
|
const template = [
|
||||||
{ role: "fileMenu" },
|
buildFileMenu(),
|
||||||
{ role: "editMenu" },
|
buildEditMenu(),
|
||||||
{ label: "View", submenu: viewSubmenu },
|
{ label: "View", submenu: viewSubmenu },
|
||||||
{ role: "windowMenu" },
|
buildWindowMenu(),
|
||||||
];
|
];
|
||||||
|
|
||||||
if (process.platform === "darwin") {
|
if (process.platform === "darwin") {
|
||||||
template.unshift({ role: "appMenu" });
|
template.unshift(buildMacAppMenu());
|
||||||
}
|
}
|
||||||
|
|
||||||
return template;
|
return template;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user