mirror of https://github.com/Fabio286/antares.git
fix: ts exceptions
This commit is contained in:
parent
ffc645ba5e
commit
df681147aa
|
@ -1,4 +1,4 @@
|
|||
import { app, ipcMain, dialog, BrowserWindow } from 'electron';
|
||||
import { app, ipcMain, dialog } from 'electron';
|
||||
import { ShortcutRegister } from '../libs/ShortcutRegister';
|
||||
|
||||
export default () => {
|
||||
|
@ -15,26 +15,22 @@ export default () => {
|
|||
});
|
||||
|
||||
ipcMain.handle('resotre-default-shortcuts', () => {
|
||||
const mainWindow = BrowserWindow.getAllWindows()[0];
|
||||
const shortCutRegister = ShortcutRegister.getInstance({ mainWindow });
|
||||
const shortCutRegister = ShortcutRegister.getInstance();
|
||||
shortCutRegister.restoreDefaults();
|
||||
});
|
||||
|
||||
ipcMain.handle('reload-shortcuts', () => {
|
||||
const mainWindow = BrowserWindow.getAllWindows()[0];
|
||||
const shortCutRegister = ShortcutRegister.getInstance({ mainWindow });
|
||||
const shortCutRegister = ShortcutRegister.getInstance();
|
||||
shortCutRegister.reload();
|
||||
});
|
||||
|
||||
ipcMain.handle('update-shortcuts', (event, shortcuts) => {
|
||||
const mainWindow = BrowserWindow.getAllWindows()[0];
|
||||
const shortCutRegister = ShortcutRegister.getInstance({ mainWindow });
|
||||
const shortCutRegister = ShortcutRegister.getInstance();
|
||||
shortCutRegister.updateShortcuts(shortcuts);
|
||||
});
|
||||
|
||||
ipcMain.handle('unregister-shortcuts', () => {
|
||||
const mainWindow = BrowserWindow.getAllWindows()[0];
|
||||
const shortCutRegister = ShortcutRegister.getInstance({ mainWindow });
|
||||
const shortCutRegister = ShortcutRegister.getInstance();
|
||||
shortCutRegister.unregister();
|
||||
});
|
||||
};
|
||||
|
|
|
@ -26,9 +26,14 @@ export class ShortcutRegister {
|
|||
this.shortcuts = shortcutsStore.get('shortcuts', defaultShortcuts) as ShortcutRecord[];
|
||||
}
|
||||
|
||||
public static getInstance (args: { mainWindow: BrowserWindow; menuTemplate: OsMenu; mode: ShortcutMode }) {
|
||||
if (!ShortcutRegister._instance)
|
||||
ShortcutRegister._instance = new ShortcutRegister(args);
|
||||
public static getInstance (args?: { mainWindow?: BrowserWindow; menuTemplate?: OsMenu; mode?: ShortcutMode }) {
|
||||
if (!ShortcutRegister._instance && args.menuTemplate !== undefined && args.mode !== undefined) {
|
||||
ShortcutRegister._instance = new ShortcutRegister({
|
||||
mainWindow: args.mainWindow,
|
||||
menuTemplate: args.menuTemplate,
|
||||
mode: args.mode
|
||||
});
|
||||
}
|
||||
|
||||
return ShortcutRegister._instance;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue