mirror of
https://github.com/viarotel-org/escrcpy.git
synced 2025-02-15 10:02:35 +01:00
22 lines
577 B
JavaScript
22 lines
577 B
JavaScript
import { BrowserWindow, ipcMain, Menu } from 'electron'
|
|
|
|
export default function (controlWindow) {
|
|
ipcMain.on('open-system-menu', openSystemMenu)
|
|
|
|
function openSystemMenu(event, args = {}) {
|
|
const { options = [], channel = 'system-menu-click' } = args
|
|
|
|
const template = options.map((item) => {
|
|
return {
|
|
label: item.label,
|
|
click() {
|
|
controlWindow.webContents.send(channel, item.value, item)
|
|
},
|
|
}
|
|
})
|
|
|
|
const menu = Menu.buildFromTemplate(template)
|
|
menu.popup(BrowserWindow.fromWebContents(event.sender))
|
|
}
|
|
}
|