From 1ea4d33b1ab10edebf1c0a96a24aae561720685d Mon Sep 17 00:00:00 2001 From: an-lee Date: Mon, 2 Dec 2024 09:37:58 +0800 Subject: [PATCH] add edit menu (#1219) --- enjoy/src/main/window.ts | 74 ++++++++++++++++++++++------------------ 1 file changed, 41 insertions(+), 33 deletions(-) diff --git a/enjoy/src/main/window.ts b/enjoy/src/main/window.ts index 2f2bfa2c..0c67e973 100644 --- a/enjoy/src/main/window.ts +++ b/enjoy/src/main/window.ts @@ -7,6 +7,7 @@ import { shell, dialog, systemPreferences, + MenuItemConstructorOptions, } from "electron"; import path from "path"; import db from "@main/db"; @@ -641,42 +642,49 @@ ${log} // mainWindow.webContents.openDevTools(); } - if (platform() === "darwin") { - const menu = Menu.buildFromTemplate([ - { - label: app.name, - submenu: [ - { role: "about" }, - { type: "separator" }, - { role: "hide" }, - { role: "unhide" }, - { type: "separator" }, - { role: "quit" }, - ], - }, - { - label: "&Help", - submenu: [ - { - label: "Check for Updates...", - click: () => { - shell.openExternal("https://1000h.org/enjoy-app/install.html"); - }, + const menuTemplate: MenuItemConstructorOptions[] = [ + { + label: app.name, + submenu: [ + { role: "about" }, + { type: "separator" }, + { role: "hide" }, + { role: "unhide" }, + { type: "separator" }, + { role: "quit" }, + ], + }, + { + label: "Edit", + submenu: [ + { role: "undo" }, + { role: "redo" }, + { type: "separator" }, + { role: "cut" }, + { role: "copy" }, + { role: "paste" }, + ], + }, + { + label: "Help", + submenu: [ + { + label: "Check for Updates...", + click: () => { + shell.openExternal("https://1000h.org/enjoy-app/install.html"); }, - { - label: "Report Issue...", - click: () => { - shell.openExternal(`${REPO_URL}/issues/new`); - }, + }, + { + label: "Report Issue...", + click: () => { + shell.openExternal(`${REPO_URL}/issues/new`); }, - ], - }, - ]); + }, + ], + }, + ]; - Menu.setApplicationMenu(menu); - } else { - Menu.setApplicationMenu(null); - } + Menu.setApplicationMenu(Menu.buildFromTemplate(menuTemplate)); main.win = mainWindow; };