parent
87c498fa91
commit
336d191c20
@ -0,0 +1,24 @@ |
||||
import {app, Menu, BrowserWindow, ipcMain} from 'electron'; |
||||
import { createWindow } from '../main'; |
||||
|
||||
|
||||
const commands: Record<string, (focusedWindow?: BrowserWindow) => void> = { |
||||
'window:new': () => { |
||||
// If window is created on the same tick, it will consume event too
|
||||
setTimeout(createWindow, 0); |
||||
}, |
||||
'folder:open': (focusedWindow) => { |
||||
if (focusedWindow) { |
||||
ipcMain.emit('fs:openFolder', focusedWindow.webContents.id); |
||||
} |
||||
} |
||||
|
||||
}; |
||||
|
||||
|
||||
export const execCommand = (command: string, focusedWindow?: BrowserWindow) => { |
||||
const fn = commands[command]; |
||||
if (fn) { |
||||
fn(focusedWindow); |
||||
} |
||||
}; |
@ -0,0 +1,56 @@ |
||||
// This menu label is overrided by OSX to be the appName
|
||||
// The label is set to appName here so it matches actual behavior
|
||||
import {app, BrowserWindow, MenuItemConstructorOptions} from 'electron'; |
||||
|
||||
export default ( |
||||
commandKeys: Record<string, string>, |
||||
execCommand: (command: string, focusedWindow?: BrowserWindow) => void, |
||||
showAbout: () => void |
||||
): MenuItemConstructorOptions => { |
||||
return { |
||||
label: `${app.name}`, |
||||
submenu: [ |
||||
{ |
||||
label: 'About Remix', |
||||
click() { |
||||
showAbout(); |
||||
} |
||||
}, |
||||
{ |
||||
type: 'separator' |
||||
}, |
||||
{ |
||||
label: 'Preferences...', |
||||
accelerator: commandKeys['window:preferences'], |
||||
click() { |
||||
execCommand('window:preferences'); |
||||
} |
||||
}, |
||||
{ |
||||
type: 'separator' |
||||
}, |
||||
{ |
||||
role: 'services', |
||||
submenu: [] |
||||
}, |
||||
{ |
||||
type: 'separator' |
||||
}, |
||||
{ |
||||
role: 'hide' |
||||
}, |
||||
{ |
||||
role: 'hideOthers' |
||||
}, |
||||
{ |
||||
role: 'unhide' |
||||
}, |
||||
{ |
||||
type: 'separator' |
||||
}, |
||||
{ |
||||
role: 'quit' |
||||
} |
||||
] |
||||
}; |
||||
}; |
@ -0,0 +1,28 @@ |
||||
import {BrowserWindow, MenuItemConstructorOptions} from 'electron'; |
||||
|
||||
export default ( |
||||
commandKeys: Record<string, string>, |
||||
execCommand: (command: string, focusedWindow?: BrowserWindow) => void |
||||
): MenuItemConstructorOptions => { |
||||
const isMac = process.platform === 'darwin'; |
||||
|
||||
return { |
||||
label: 'File', |
||||
submenu: [ |
||||
{ |
||||
label: 'New Window', |
||||
accelerator: commandKeys['window:new'], |
||||
click(item, focusedWindow) { |
||||
execCommand('window:new', focusedWindow); |
||||
} |
||||
}, |
||||
{ |
||||
label: 'Open Folder', |
||||
accelerator: commandKeys['folder:open'], |
||||
click(item, focusedWindow) { |
||||
execCommand('folder:open', focusedWindow); |
||||
} |
||||
} |
||||
] |
||||
}; |
||||
}; |
@ -0,0 +1,26 @@ |
||||
import {BrowserWindow, MenuItemConstructorOptions} from 'electron'; |
||||
|
||||
export default ( |
||||
commandKeys: Record<string, string>, |
||||
execCommand: (command: string, focusedWindow?: BrowserWindow) => void |
||||
): MenuItemConstructorOptions => { |
||||
const isMac = process.platform === 'darwin'; |
||||
|
||||
return { |
||||
label: 'REMIX', |
||||
submenu: [ |
||||
{ |
||||
label: 'Close', |
||||
accelerator: commandKeys['pane:close'], |
||||
click(item, focusedWindow) { |
||||
execCommand('pane:close', focusedWindow); |
||||
} |
||||
}, |
||||
{ |
||||
label: isMac ? 'Close Window' : 'Quit', |
||||
role: 'close', |
||||
accelerator: commandKeys['window:close'] |
||||
} |
||||
] |
||||
}; |
||||
}; |
Loading…
Reference in new issue