2
0
mirror of https://github.com/frappe/books.git synced 2024-11-10 07:40:55 +00:00
books/main/registerIpcMainMessageListeners.ts

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

39 lines
945 B
TypeScript
Raw Normal View History

import { ipcMain, Menu, shell } from 'electron';
import { Main } from '../main';
2022-03-31 07:33:58 +00:00
import { IPC_MESSAGES } from '../utils/messages';
export default function registerIpcMainMessageListeners(main: Main) {
ipcMain.on(IPC_MESSAGES.OPEN_MENU, (event) => {
if (event.sender === null) {
return;
}
const menu = Menu.getApplicationMenu();
if (menu === null) {
return;
}
menu.popup({ window: main.mainWindow! });
});
ipcMain.on(IPC_MESSAGES.RELOAD_MAIN_WINDOW, () => {
main.mainWindow!.reload();
});
2022-05-27 10:47:24 +00:00
ipcMain.on(IPC_MESSAGES.CLOSE_CURRENT_WINDOW, () => {
main.mainWindow!.close();
});
2022-05-27 10:47:24 +00:00
ipcMain.on(IPC_MESSAGES.MINIMIZE_CURRENT_WINDOW, () => {
main.mainWindow!.minimize();
});
2022-05-27 10:47:24 +00:00
ipcMain.on(IPC_MESSAGES.OPEN_EXTERNAL, (_, link) => {
shell.openExternal(link);
});
2022-05-27 10:47:24 +00:00
ipcMain.on(IPC_MESSAGES.SHOW_ITEM_IN_FOLDER, (_, filePath) => {
return shell.showItemInFolder(filePath);
});
}