From 2b8ecf039b1c52e797aa731d6859a95f1e1cfbbf Mon Sep 17 00:00:00 2001 From: DIYgod Date: Sat, 18 May 2024 01:30:20 +0800 Subject: [PATCH] feat: set application menu --- src/main/window.ts | 26 ++++++++++++++++++- .../src/components/feed-column/index.tsx | 2 +- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/src/main/window.ts b/src/main/window.ts index b34aa0ebd..831d061b6 100644 --- a/src/main/window.ts +++ b/src/main/window.ts @@ -1,4 +1,4 @@ -import { app, shell, BrowserWindow } from "electron" +import { app, shell, BrowserWindow, Menu } from "electron" import path from "path" import { is } from "@electron-toolkit/utils" import icon from "../../resources/icon.png?asset" @@ -93,6 +93,30 @@ export function createWindow(): void { }, ) + Menu.setApplicationMenu( + Menu.buildFromTemplate([ + { + role: "appMenu", + submenu: [ + { role: "about" }, + { type: "separator" }, + { + label: "Settings...", + accelerator: "CmdOrCtrl+,", + click: () => { + console.log("Oh, hi there!") + }, + }, + { type: "separator" }, + { role: "hide" }, + { role: "quit" }, + ], + }, + { role: "viewMenu" }, + { role: "windowMenu" }, + ]), + ) + app.on("second-instance", (_, commandLine) => { if (mainWindow) { if (mainWindow.isMinimized()) mainWindow.restore() diff --git a/src/renderer/src/components/feed-column/index.tsx b/src/renderer/src/components/feed-column/index.tsx index be952b9d8..1c436cff4 100644 --- a/src/renderer/src/components/feed-column/index.tsx +++ b/src/renderer/src/components/feed-column/index.tsx @@ -86,7 +86,7 @@ export function FeedColumn({