diff --git a/desktop/index.ts b/desktop/index.ts index 3e6b5b8e8..a3d30de1a 100644 --- a/desktop/index.ts +++ b/desktop/index.ts @@ -1,4 +1,4 @@ -import { app, dialog, BrowserWindow } from 'electron' +import { app, dialog, BrowserWindow, Menu } from 'electron' import { electronApp, optimizer } from '@electron-toolkit/utils' import { createWindow } from './window' import { createBridge } from './bridge' @@ -10,6 +10,7 @@ import * as server from './server' import * as python from './python' import * as settings from './settings' import * as resources from './resources' +const { mainMenu } = require('./menu.ts') // This method will be called when Electron has finished // initialization and is ready to create browser windows. @@ -69,3 +70,5 @@ process.on('unhandledRejection', async (error: any) => { // Configure logger to write to the app directory log.transports.file.resolvePath = () => join(settings.APP_HOME, 'logger', 'main.log') + +Menu.setApplicationMenu(mainMenu) \ No newline at end of file diff --git a/desktop/menu.ts b/desktop/menu.ts new file mode 100644 index 000000000..19af17e12 --- /dev/null +++ b/desktop/menu.ts @@ -0,0 +1,75 @@ +import { app, Menu, MenuItemConstructorOptions } from 'electron' + +const isMac = process.platform === 'darwin' + +const template = [ + ...(isMac ? [{ + label: app.name, + submenu: [ + { role: 'about' }, + { type: 'separator' }, + { type: 'separator' }, + { role: 'quit' } + ] + }]: []) as MenuItemConstructorOptions[], + // { role: fileMenu } + { + label: 'Fileyooo', + submenu: [ + { + label: 'Open file', + click: async () => { + //doOpenFile() + } + } + ] as MenuItemConstructorOptions[] + }, + // { role: 'editMenu' } + { + label: 'Edituuuu', + submenu: [ + { role: 'undo' }, + { role: 'redo' }, + { type: 'separator' }, + { role: 'cut' }, + { role: 'copy' }, + { role: 'paste' }, + ...(isMac + ? [ + { role: 'pasteAndMatchStyle' }, + { role: 'delete' }, + { role: 'selectAll' }, + { type: 'separator' }, + { + label: 'Speech', + submenu: [ + { role: 'startSpeaking' }, + { role: 'stopSpeaking' } + ] + } + ] + : [ + { role: 'delete' }, + { type: 'separator' }, + { role: 'selectAll' } + ]) + ] as MenuItemConstructorOptions[] + }, + // { role: 'viewMenu' } + { + label: 'View', + submenu: [ + { role: 'reload' }, + { role: 'forceReload' }, + { role: 'toggleDevTools' }, + { type: 'separator' }, + { role: 'resetZoom' }, + { role: 'zoomIn' }, + { role: 'zoomOut' }, + { type: 'separator' }, + { role: 'togglefullscreen' } + ] as MenuItemConstructorOptions[] + }, +] + +module.exports.mainMenu = Menu.buildFromTemplate(template) \ No newline at end of file