Remove unused menu

This commit is contained in:
AkiraFukushima 2024-09-12 23:50:39 +09:00
parent 58414835e5
commit 7c84ae1789
No known key found for this signature in database
GPG Key ID: B7EA3A3C9AEC9F0E
3 changed files with 82 additions and 2 deletions

View File

@ -1,7 +1,8 @@
import path from 'path'
import { app, ipcMain, shell, IpcMainInvokeEvent, BrowserWindow } from 'electron'
import { app, ipcMain, shell, IpcMainInvokeEvent, BrowserWindow, Menu } from 'electron'
import serve from 'electron-serve'
import { createWindow } from './helpers'
import { menu } from './menu'
const isProd = process.env.NODE_ENV === 'production'
@ -16,6 +17,8 @@ let main: BrowserWindow = null
;(async () => {
await app.whenReady()
Menu.setApplicationMenu(menu)
const mainWindow = createWindow('main', {
width: 1000,
height: 600,

77
main/menu.ts Normal file
View File

@ -0,0 +1,77 @@
import { app, Menu, MenuItem, MenuItemConstructorOptions } from 'electron'
const isDarwin = () => process.platform === 'darwin'
const template: Array<MenuItemConstructorOptions | MenuItem> = [
...(isDarwin()
? ([
{
label: app.name,
submenu: [
{ role: 'about' },
{ type: 'separator' },
{ role: 'services' },
{ type: 'separator' },
{ role: 'hide' },
{ role: 'hideOthers' },
{ role: 'unhide' },
{ type: 'separator' },
{ role: 'quit' }
]
}
] as Array<MenuItemConstructorOptions | MenuItem>)
: ([] as Array<MenuItem>)),
{
label: 'File',
submenu: [isDarwin() ? { role: 'close' } : { role: 'quit' }]
},
{
label: 'Edit',
submenu: [
{ role: 'undo' },
{ role: 'redo' },
{ type: 'separator' },
{ role: 'cut' },
{ role: 'copy' },
{ role: 'paste' },
...(isDarwin()
? ([
{ role: 'pasteAndMatchStyle' },
{ role: 'delete' },
{ role: 'selectAll' },
{ type: 'separator' },
{
label: 'Speech',
submenu: [{ role: 'startSpeaking' }, { role: 'stopSpeaking' }]
}
] as Array<MenuItemConstructorOptions>)
: ([{ role: 'delete' }, { type: 'separator' }, { role: 'selectAll' }] as Array<MenuItemConstructorOptions>))
]
},
{
label: 'View',
submenu: [
{ role: 'reload' },
{ role: 'forceReload' },
{ role: 'toggleDevTools' },
{ type: 'separator' },
{ role: 'resetZoom' },
{ role: 'zoomIn' },
{ role: 'zoomOut' },
{ type: 'separator' },
{ role: 'togglefullscreen' }
]
},
{
label: 'Window',
submenu: [
{ role: 'minimize' },
{ role: 'zoom' },
...(isDarwin()
? ([{ type: 'separator' }, { role: 'front' }, { type: 'separator' }, { role: 'window' }] as Array<MenuItemConstructorOptions>)
: ([{ role: 'close' }] as Array<MenuItemConstructorOptions>))
]
}
]
export const menu = Menu.buildFromTemplate(template)

View File

@ -2,4 +2,4 @@
/// <reference types="next/image-types/global" />
// NOTE: This file should not be edited
// see https://nextjs.org/docs/basic-features/typescript for more information.
// see https://nextjs.org/docs/pages/building-your-application/configuring/typescript for more information.