mirror of
https://github.com/dbgate/dbgate
synced 2024-11-07 20:26:23 +00:00
mac main menu
This commit is contained in:
parent
90f8d349fc
commit
6d92de6930
@ -49,12 +49,22 @@ autoUpdater.logger = log;
|
||||
|
||||
let commands = {};
|
||||
|
||||
function formatKeyText(keyText) {
|
||||
if (!keyText) {
|
||||
return keyText;
|
||||
}
|
||||
if (os.platform() == 'darwin') {
|
||||
return keyText.replace('CtrlOrCommand+', 'Command+');
|
||||
}
|
||||
return keyText;
|
||||
}
|
||||
|
||||
function commandItem(id) {
|
||||
const command = commands[id];
|
||||
return {
|
||||
id,
|
||||
label: command ? command.menuName || command.toolbarName || command.name : id,
|
||||
accelerator: command ? command.keyText : undefined,
|
||||
accelerator: formatKeyText(command ? command.keyText : undefined),
|
||||
enabled: command ? command.enabled : false,
|
||||
click() {
|
||||
mainWindow.webContents.send('run-command', id);
|
||||
@ -86,7 +96,9 @@ ipcMain.on('update-commands', async (event, arg) => {
|
||||
// rebuild menu
|
||||
if (menu.label != command.text || menu.accelerator != command.keyText) {
|
||||
mainMenu = buildMenu();
|
||||
mainWindow.setMenu(mainMenu);
|
||||
|
||||
Menu.setApplicationMenu(mainMenu);
|
||||
// mainWindow.setMenu(mainMenu);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
import { commandsCustomized, visibleCommandPalette } from '../stores';
|
||||
import { get } from 'svelte/store';
|
||||
import { runGroupCommand } from './runCommand';
|
||||
import { resolveKeyText } from '../utility/common';
|
||||
import { resolveKeyText } from '../utility/common';
|
||||
|
||||
export function handleCommandKeyDown(e) {
|
||||
let keyText = '';
|
||||
|
Loading…
Reference in New Issue
Block a user