mirror of
https://github.com/HugoAura/Seewo-HugoAura.git
synced 2026-06-21 23:54:26 +08:00
60 lines
1.4 KiB
JavaScript
60 lines
1.4 KiB
JavaScript
// @ts-check
|
|
|
|
const { BrowserWindow } = require("electron");
|
|
|
|
const composables = {
|
|
getBrowserWindowInstance: (windowKey) => {
|
|
if (!global.__HUGO_AURA__.hookedWindows) return null;
|
|
const hookedWindowIns = global.__HUGO_AURA__.hookedWindows.get(windowKey);
|
|
if (!hookedWindowIns) return undefined;
|
|
const browserWindowIns = BrowserWindow.fromWebContents(
|
|
hookedWindowIns.webContents
|
|
);
|
|
return browserWindowIns;
|
|
},
|
|
};
|
|
|
|
/**
|
|
*
|
|
* @param {import("electron").IpcMain} ipcMain
|
|
*/
|
|
const applyBaseIpcHandler = (ipcMain) => {
|
|
const methodBase = "$aura.base";
|
|
|
|
ipcMain.on(
|
|
`${methodBase}.minimizeWindow`,
|
|
/**
|
|
*
|
|
* @param {import("electron").IpcMainEvent} _event
|
|
* @param {{ targetWindowKey: string }} arg
|
|
*/
|
|
(_event, arg) => {
|
|
const browserWindowIns = composables.getBrowserWindowInstance(
|
|
arg.targetWindowKey
|
|
);
|
|
if (!browserWindowIns) return;
|
|
|
|
browserWindowIns.minimize();
|
|
}
|
|
);
|
|
|
|
ipcMain.on(
|
|
`${methodBase}.closeWindow`,
|
|
/**
|
|
*
|
|
* @param {import("electron").IpcMainEvent} _event
|
|
* @param {{ targetWindowKey: string }} arg
|
|
*/
|
|
(_event, arg) => {
|
|
const browserWindowIns = composables.getBrowserWindowInstance(
|
|
arg.targetWindowKey
|
|
);
|
|
if (!browserWindowIns) return;
|
|
|
|
browserWindowIns.close();
|
|
}
|
|
);
|
|
};
|
|
|
|
module.exports = { applyBaseIpcHandler };
|