Skip to content

Commit

Permalink
fix: setting window can multi create (#64)
Browse files Browse the repository at this point in the history
Signed-off-by: Innei <i@innei.in>
  • Loading branch information
Innei authored Jun 14, 2024
1 parent fbeb00e commit 396a7d7
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions src/main/menu.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
import type { MenuItem, MenuItemConstructorOptions } from "electron"
import type {
BrowserWindow,
MenuItem,
MenuItemConstructorOptions,
} from "electron"
import { Menu } from "electron"

import { createWindow } from "./window"

const windows = {
settingWindow: null as BrowserWindow | null,
}
export const registerAppMenu = () => {
const menus: Array<MenuItemConstructorOptions | MenuItem> = [
{
Expand All @@ -14,10 +21,20 @@ export const registerAppMenu = () => {
label: "Settings...",
accelerator: "CmdOrCtrl+,",
click: () => {
createWindow({
if (windows.settingWindow) {
windows.settingWindow.show()
return
}
const window = createWindow({
extraPath: "/settings",
width: 800,
height: 600,
resizable: false,
})

windows.settingWindow = window
window.on("closed", () => {
windows.settingWindow = null
})
},
},
Expand Down

0 comments on commit 396a7d7

Please sign in to comment.