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';
|
import { ShortcutRegister } from '../libs/ShortcutRegister';
|
||||||
|
|
||||||
export default () => {
|
export default () => {
|
||||||
|
@ -15,26 +15,22 @@ export default () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
ipcMain.handle('resotre-default-shortcuts', () => {
|
ipcMain.handle('resotre-default-shortcuts', () => {
|
||||||
const mainWindow = BrowserWindow.getAllWindows()[0];
|
const shortCutRegister = ShortcutRegister.getInstance();
|
||||||
const shortCutRegister = ShortcutRegister.getInstance({ mainWindow });
|
|
||||||
shortCutRegister.restoreDefaults();
|
shortCutRegister.restoreDefaults();
|
||||||
});
|
});
|
||||||
|
|
||||||
ipcMain.handle('reload-shortcuts', () => {
|
ipcMain.handle('reload-shortcuts', () => {
|
||||||
const mainWindow = BrowserWindow.getAllWindows()[0];
|
const shortCutRegister = ShortcutRegister.getInstance();
|
||||||
const shortCutRegister = ShortcutRegister.getInstance({ mainWindow });
|
|
||||||
shortCutRegister.reload();
|
shortCutRegister.reload();
|
||||||
});
|
});
|
||||||
|
|
||||||
ipcMain.handle('update-shortcuts', (event, shortcuts) => {
|
ipcMain.handle('update-shortcuts', (event, shortcuts) => {
|
||||||
const mainWindow = BrowserWindow.getAllWindows()[0];
|
const shortCutRegister = ShortcutRegister.getInstance();
|
||||||
const shortCutRegister = ShortcutRegister.getInstance({ mainWindow });
|
|
||||||
shortCutRegister.updateShortcuts(shortcuts);
|
shortCutRegister.updateShortcuts(shortcuts);
|
||||||
});
|
});
|
||||||
|
|
||||||
ipcMain.handle('unregister-shortcuts', () => {
|
ipcMain.handle('unregister-shortcuts', () => {
|
||||||
const mainWindow = BrowserWindow.getAllWindows()[0];
|
const shortCutRegister = ShortcutRegister.getInstance();
|
||||||
const shortCutRegister = ShortcutRegister.getInstance({ mainWindow });
|
|
||||||
shortCutRegister.unregister();
|
shortCutRegister.unregister();
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
|
@ -26,9 +26,14 @@ export class ShortcutRegister {
|
||||||
this.shortcuts = shortcutsStore.get('shortcuts', defaultShortcuts) as ShortcutRecord[];
|
this.shortcuts = shortcutsStore.get('shortcuts', defaultShortcuts) as ShortcutRecord[];
|
||||||
}
|
}
|
||||||
|
|
||||||
public static getInstance (args: { mainWindow: BrowserWindow; menuTemplate: OsMenu; mode: ShortcutMode }) {
|
public static getInstance (args?: { mainWindow?: BrowserWindow; menuTemplate?: OsMenu; mode?: ShortcutMode }) {
|
||||||
if (!ShortcutRegister._instance)
|
if (!ShortcutRegister._instance && args.menuTemplate !== undefined && args.mode !== undefined) {
|
||||||
ShortcutRegister._instance = new ShortcutRegister(args);
|
ShortcutRegister._instance = new ShortcutRegister({
|
||||||
|
mainWindow: args.mainWindow,
|
||||||
|
menuTemplate: args.menuTemplate,
|
||||||
|
mode: args.mode
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
return ShortcutRegister._instance;
|
return ShortcutRegister._instance;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue