From e3cb196038ba9346489a5567cc6fcf047dabd702 Mon Sep 17 00:00:00 2001 From: junghyunbak Date: Wed, 11 Dec 2024 14:13:24 +0900 Subject: [PATCH] =?UTF-8?q?chore:=20erb=20default=20menu=20=EC=84=A4?= =?UTF-8?q?=EC=A0=95=20=EC=82=AC=EC=9A=A9=ED=95=98=EB=8F=84=EB=A1=9D=20?= =?UTF-8?q?=EC=84=A4=EC=A0=95=20(Mac=EC=9D=98=20=EA=B2=BD=EC=9A=B0?= =?UTF-8?q?=EC=97=90=EB=A7=8C)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/main.ts | 22 +++------------------- src/main/menu.ts | 42 +++++++++--------------------------------- 2 files changed, 12 insertions(+), 52 deletions(-) diff --git a/src/main/main.ts b/src/main/main.ts index cd0041e..fd87815 100644 --- a/src/main/main.ts +++ b/src/main/main.ts @@ -10,7 +10,7 @@ */ import path from 'path'; import fs from 'fs'; -import { app, BrowserWindow, shell, globalShortcut, Menu, MenuItemConstructorOptions } from 'electron'; +import { app, BrowserWindow, shell, globalShortcut } from 'electron'; import puppeteer from 'puppeteer-core'; import pie from 'puppeteer-in-electron'; import { spawnSync } from 'child_process'; @@ -22,6 +22,7 @@ import { Code } from './sub/code'; import { Judge } from './sub/judge'; import '@/error/sentry'; +import MenuBuilder from './menu'; let mainWindow: BrowserWindow | null = null; let bojView: BojView | null = null; @@ -84,24 +85,7 @@ const createWindow = async (puppeteerBroswer: Awaited { - app.quit(); - }, - }, - ], - }); - } - - Menu.setApplicationMenu(Menu.buildFromTemplate(menuOptions)); + new MenuBuilder(mainWindow).buildMenu(); mainWindow.on('ready-to-show', () => { if (!mainWindow) { diff --git a/src/main/menu.ts b/src/main/menu.ts index ba0fb77..e6aa1c9 100644 --- a/src/main/menu.ts +++ b/src/main/menu.ts @@ -1,10 +1,4 @@ -import { - app, - Menu, - shell, - BrowserWindow, - MenuItemConstructorOptions, -} from 'electron'; +import { app, Menu, shell, BrowserWindow, MenuItemConstructorOptions } from 'electron'; interface DarwinMenuItemConstructorOptions extends MenuItemConstructorOptions { selector?: string; @@ -19,17 +13,11 @@ export default class MenuBuilder { } buildMenu(): Menu { - if ( - process.env.NODE_ENV === 'development' || - process.env.DEBUG_PROD === 'true' - ) { + if (process.env.NODE_ENV === 'development' || process.env.DEBUG_PROD === 'true') { this.setupDevelopmentEnvironment(); } - const template = - process.platform === 'darwin' - ? this.buildDarwinTemplate() - : this.buildDefaultTemplate(); + const template = process.platform === 'darwin' ? this.buildDarwinTemplate() : []; const menu = Menu.buildFromTemplate(template); Menu.setApplicationMenu(menu); @@ -163,9 +151,7 @@ export default class MenuBuilder { { label: 'Documentation', click() { - shell.openExternal( - 'https://github.com/electron/electron/tree/main/docs#readme', - ); + shell.openExternal('https://github.com/electron/electron/tree/main/docs#readme'); }, }, { @@ -184,10 +170,7 @@ export default class MenuBuilder { }; const subMenuView = - process.env.NODE_ENV === 'development' || - process.env.DEBUG_PROD === 'true' - ? subMenuViewDev - : subMenuViewProd; + process.env.NODE_ENV === 'development' || process.env.DEBUG_PROD === 'true' ? subMenuViewDev : subMenuViewProd; return [subMenuAbout, subMenuEdit, subMenuView, subMenuWindow, subMenuHelp]; } @@ -213,8 +196,7 @@ export default class MenuBuilder { { label: '&View', submenu: - process.env.NODE_ENV === 'development' || - process.env.DEBUG_PROD === 'true' + process.env.NODE_ENV === 'development' || process.env.DEBUG_PROD === 'true' ? [ { label: '&Reload', @@ -227,9 +209,7 @@ export default class MenuBuilder { label: 'Toggle &Full Screen', accelerator: 'F11', click: () => { - this.mainWindow.setFullScreen( - !this.mainWindow.isFullScreen(), - ); + this.mainWindow.setFullScreen(!this.mainWindow.isFullScreen()); }, }, { @@ -245,9 +225,7 @@ export default class MenuBuilder { label: 'Toggle &Full Screen', accelerator: 'F11', click: () => { - this.mainWindow.setFullScreen( - !this.mainWindow.isFullScreen(), - ); + this.mainWindow.setFullScreen(!this.mainWindow.isFullScreen()); }, }, ], @@ -264,9 +242,7 @@ export default class MenuBuilder { { label: 'Documentation', click() { - shell.openExternal( - 'https://github.com/electron/electron/tree/main/docs#readme', - ); + shell.openExternal('https://github.com/electron/electron/tree/main/docs#readme'); }, }, {