From 5320a5846cfa3a4e7679d068378f88ee31f33345 Mon Sep 17 00:00:00 2001 From: mozzie Date: Sun, 11 Aug 2024 21:29:23 +0800 Subject: [PATCH] feat: menubar icon --- electron/main.ts | 7 ++++--- src/pages/Layout.tsx | 6 +++--- src/pages/MenuBar.tsx | 2 +- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/electron/main.ts b/electron/main.ts index 9473007..55dbbdf 100644 --- a/electron/main.ts +++ b/electron/main.ts @@ -61,12 +61,10 @@ function createWindow() { } else { win.loadFile(path.join(RENDERER_DIST, "index.html")); } - - createTray(); - registerGlobalShortcuts(); } function createTray() { + if (tray) tray.destroy() const iconPath = path.join(process.env.VITE_PUBLIC, "AI.png"); // 使用 PNG 图标 const icon = nativeImage .createFromPath(iconPath) @@ -124,6 +122,8 @@ app.on("activate", () => { app.whenReady().then(() => { createWindow(); + createTray(); + registerGlobalShortcuts(); registerIpcMainHandlers(win); // 设置 Dock 图标 @@ -137,4 +137,5 @@ app.whenReady().then(() => { // 注销全局快捷键,当应用退出时 app.on("will-quit", () => { globalShortcut.unregisterAll(); + tray?.destroy() }); diff --git a/src/pages/Layout.tsx b/src/pages/Layout.tsx index 30bccfc..385359d 100644 --- a/src/pages/Layout.tsx +++ b/src/pages/Layout.tsx @@ -5,16 +5,16 @@ import { MenuBar } from "./MenuBar"; const LayoutMain = () => { const platform = document.querySelector("html")?.getAttribute("platform") ?? "macos"; - - const titleBarStyles = - platform === "macos" ? "pl-[5rem] pr-[.5rem]" : "pr-[10rem]"; + platform === "macos" ? "pl-[5rem] pr-[.5rem]" : "pl-[.5rem]"; + return (
+
diff --git a/src/pages/MenuBar.tsx b/src/pages/MenuBar.tsx index ecba37a..afa4573 100644 --- a/src/pages/MenuBar.tsx +++ b/src/pages/MenuBar.tsx @@ -24,7 +24,7 @@ export const MenuBar = () => { }); return () => { - window.ipcRenderer.off(EVENT_PARSE_DICOM + ":RES", () => {}); + window.ipcRenderer.off(EVENT_PARSE_DICOM + ":RES", () => { }); }; }, []);