2024-09-13 19:38:29 +08:00
|
|
|
import { BrowserWindow, ipcMain, Menu } from 'electron'
|
|
|
|
|
|
|
|
export default function (controlWindow) {
|
2024-09-16 15:33:24 +08:00
|
|
|
ipcMain.on('open-device-rotation-menu', openDeviceRotationMenu)
|
2024-09-13 19:38:29 +08:00
|
|
|
|
|
|
|
function openDeviceRotationMenu(event, args = {}) {
|
|
|
|
const { options = [] } = args
|
|
|
|
|
|
|
|
const template = options.map((item) => {
|
|
|
|
return {
|
|
|
|
label: item.label,
|
|
|
|
click: () => {
|
|
|
|
controlWindow.webContents.send(
|
|
|
|
'execute-device-rotation-shell',
|
|
|
|
item.value,
|
|
|
|
)
|
|
|
|
},
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
const menu = Menu.buildFromTemplate(template)
|
|
|
|
menu.popup(BrowserWindow.fromWebContents(event.sender))
|
|
|
|
}
|
|
|
|
}
|