mirror of
https://github.com/quine-global/hyper.git
synced 2026-01-15 21:28:40 -09:00
More ts fixes
This commit is contained in:
parent
a9cb042bd6
commit
85e6a0d2c8
5 changed files with 20 additions and 20 deletions
|
|
@ -1,12 +1,12 @@
|
||||||
import {app, Menu} from 'electron';
|
import {app, Menu} from 'electron';
|
||||||
import type {BaseWindow} from 'electron';
|
import type {BaseWindow, BrowserWindow} from 'electron';
|
||||||
|
|
||||||
import {openConfig, getConfig} from './config';
|
import {openConfig, getConfig} from './config';
|
||||||
import {updatePlugins} from './plugins';
|
import {updatePlugins} from './plugins';
|
||||||
import {installCLI} from './utils/cli-install';
|
import {installCLI} from './utils/cli-install';
|
||||||
import * as systemContextMenu from './utils/system-context-menu';
|
import * as systemContextMenu from './utils/system-context-menu';
|
||||||
|
|
||||||
const commands: Record<string, (focusedWindow?: any) => void> = {
|
const commands: Record<string, (focusedWindow?: BrowserWindow) => void> = {
|
||||||
'window:new': () => {
|
'window:new': () => {
|
||||||
// If window is created on the same tick, it will consume event too
|
// If window is created on the same tick, it will consume event too
|
||||||
setTimeout(app.createWindow, 0);
|
setTimeout(app.createWindow, 0);
|
||||||
|
|
@ -162,7 +162,7 @@ getConfig().profiles.forEach((profile) => {
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
export const execCommand = (command: string, focusedWindow?: BaseWindow) => {
|
export const execCommand = (command: string, focusedWindow?: BrowserWindow) => {
|
||||||
const fn = commands[command];
|
const fn = commands[command];
|
||||||
if (fn) {
|
if (fn) {
|
||||||
fn(focusedWindow);
|
fn(focusedWindow);
|
||||||
|
|
|
||||||
|
|
@ -65,7 +65,7 @@ export const createMenu = (
|
||||||
...(process.platform === 'darwin' ? [darwinMenu(commandKeys, execCommand, showAbout)] : []),
|
...(process.platform === 'darwin' ? [darwinMenu(commandKeys, execCommand, showAbout)] : []),
|
||||||
shellMenu(
|
shellMenu(
|
||||||
commandKeys,
|
commandKeys,
|
||||||
execCommand,
|
(command, focusedWindow) => execCommand(command, focusedWindow as BrowserWindow | undefined),
|
||||||
getConfig().profiles.map((p) => p.name)
|
getConfig().profiles.map((p) => p.name)
|
||||||
),
|
),
|
||||||
editMenu(commandKeys, execCommand),
|
editMenu(commandKeys, execCommand),
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
import type {BaseWindow, MenuItemConstructorOptions} from 'electron';
|
import type {BaseWindow, BrowserWindow, MenuItemConstructorOptions} from 'electron';
|
||||||
|
|
||||||
const viewMenu = (
|
const viewMenu = (
|
||||||
commandKeys: Record<string, string>,
|
commandKeys: Record<string, string>,
|
||||||
execCommand: (command: string, focusedWindow?: BaseWindow) => void
|
execCommand: (command: string, focusedWindow?: BrowserWindow) => void
|
||||||
): MenuItemConstructorOptions => {
|
): MenuItemConstructorOptions => {
|
||||||
return {
|
return {
|
||||||
label: 'View',
|
label: 'View',
|
||||||
|
|
@ -11,21 +11,21 @@ const viewMenu = (
|
||||||
label: 'Reload',
|
label: 'Reload',
|
||||||
accelerator: commandKeys['window:reload'],
|
accelerator: commandKeys['window:reload'],
|
||||||
click(item, focusedWindow) {
|
click(item, focusedWindow) {
|
||||||
execCommand('window:reload', focusedWindow);
|
execCommand('window:reload', focusedWindow as BrowserWindow);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: 'Full Reload',
|
label: 'Full Reload',
|
||||||
accelerator: commandKeys['window:reloadFull'],
|
accelerator: commandKeys['window:reloadFull'],
|
||||||
click(item, focusedWindow) {
|
click(item, focusedWindow) {
|
||||||
execCommand('window:reloadFull', focusedWindow);
|
execCommand('window:reloadFull', focusedWindow as BrowserWindow);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: 'Developer Tools',
|
label: 'Developer Tools',
|
||||||
accelerator: commandKeys['window:devtools'],
|
accelerator: commandKeys['window:devtools'],
|
||||||
click: (item, focusedWindow) => {
|
click: (item, focusedWindow) => {
|
||||||
execCommand('window:devtools', focusedWindow);
|
execCommand('window:devtools', focusedWindow as BrowserWindow);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
@ -35,21 +35,21 @@ const viewMenu = (
|
||||||
label: 'Reset Zoom Level',
|
label: 'Reset Zoom Level',
|
||||||
accelerator: commandKeys['zoom:reset'],
|
accelerator: commandKeys['zoom:reset'],
|
||||||
click(item, focusedWindow) {
|
click(item, focusedWindow) {
|
||||||
execCommand('zoom:reset', focusedWindow);
|
execCommand('zoom:reset', focusedWindow as BrowserWindow);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: 'Zoom In',
|
label: 'Zoom In',
|
||||||
accelerator: commandKeys['zoom:in'],
|
accelerator: commandKeys['zoom:in'],
|
||||||
click(item, focusedWindow) {
|
click(item, focusedWindow) {
|
||||||
execCommand('zoom:in', focusedWindow);
|
execCommand('zoom:in', focusedWindow as BrowserWindow);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: 'Zoom Out',
|
label: 'Zoom Out',
|
||||||
accelerator: commandKeys['zoom:out'],
|
accelerator: commandKeys['zoom:out'],
|
||||||
click(item, focusedWindow) {
|
click(item, focusedWindow) {
|
||||||
execCommand('zoom:out', focusedWindow);
|
execCommand('zoom:out', focusedWindow as BrowserWindow);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
import type {BaseWindow, MenuItemConstructorOptions} from 'electron';
|
import type {BaseWindow, BrowserWindow, MenuItemConstructorOptions} from 'electron';
|
||||||
|
|
||||||
const windowMenu = (
|
const windowMenu = (
|
||||||
commandKeys: Record<string, string>,
|
commandKeys: Record<string, string>,
|
||||||
execCommand: (command: string, focusedWindow?: BaseWindow) => void
|
execCommand: (command: string, focusedWindow?: BrowserWindow) => void
|
||||||
): MenuItemConstructorOptions => {
|
): MenuItemConstructorOptions => {
|
||||||
// Generating tab:jump array
|
// Generating tab:jump array
|
||||||
const tabJump: MenuItemConstructorOptions[] = [];
|
const tabJump: MenuItemConstructorOptions[] = [];
|
||||||
|
|
@ -37,14 +37,14 @@ const windowMenu = (
|
||||||
label: 'Previous',
|
label: 'Previous',
|
||||||
accelerator: commandKeys['tab:prev'],
|
accelerator: commandKeys['tab:prev'],
|
||||||
click: (item, focusedWindow) => {
|
click: (item, focusedWindow) => {
|
||||||
execCommand('tab:prev', focusedWindow);
|
execCommand('tab:prev', focusedWindow as BrowserWindow);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: 'Next',
|
label: 'Next',
|
||||||
accelerator: commandKeys['tab:next'],
|
accelerator: commandKeys['tab:next'],
|
||||||
click: (item, focusedWindow) => {
|
click: (item, focusedWindow) => {
|
||||||
execCommand('tab:next', focusedWindow);
|
execCommand('tab:next', focusedWindow as BrowserWindow);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
@ -63,14 +63,14 @@ const windowMenu = (
|
||||||
label: 'Previous',
|
label: 'Previous',
|
||||||
accelerator: commandKeys['pane:prev'],
|
accelerator: commandKeys['pane:prev'],
|
||||||
click: (item, focusedWindow) => {
|
click: (item, focusedWindow) => {
|
||||||
execCommand('pane:prev', focusedWindow);
|
execCommand('pane:prev', focusedWindow as BrowserWindow);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: 'Next',
|
label: 'Next',
|
||||||
accelerator: commandKeys['pane:next'],
|
accelerator: commandKeys['pane:next'],
|
||||||
click: (item, focusedWindow) => {
|
click: (item, focusedWindow) => {
|
||||||
execCommand('pane:next', focusedWindow);
|
execCommand('pane:next', focusedWindow as BrowserWindow);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
@ -84,7 +84,7 @@ const windowMenu = (
|
||||||
{
|
{
|
||||||
label: 'Toggle Always on Top',
|
label: 'Toggle Always on Top',
|
||||||
click: (item, focusedWindow) => {
|
click: (item, focusedWindow) => {
|
||||||
execCommand('window:toggleKeepOnTop', focusedWindow);
|
execCommand('window:toggleKeepOnTop', focusedWindow as BrowserWindow);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@ const contextMenuTemplate = (
|
||||||
const commandKeys = getCommandKeys(getDecoratedKeymaps());
|
const commandKeys = getCommandKeys(getDecoratedKeymaps());
|
||||||
const _shell = shellMenu(
|
const _shell = shellMenu(
|
||||||
commandKeys,
|
commandKeys,
|
||||||
execCommand,
|
(command, focusedWindow) => execCommand(command, focusedWindow as BrowserWindow | undefined),
|
||||||
getProfiles().map((p) => p.name)
|
getProfiles().map((p) => p.name)
|
||||||
).submenu as MenuItemConstructorOptions[];
|
).submenu as MenuItemConstructorOptions[];
|
||||||
const _edit = editMenu(commandKeys, execCommand).submenu.filter(filterCutCopy.bind(null, selection));
|
const _edit = editMenu(commandKeys, execCommand).submenu.filter(filterCutCopy.bind(null, selection));
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue