(entry: DesktopMenuEntry, deps: Deps)
| 33 | } |
| 34 | |
| 35 | function nativeItem(entry: DesktopMenuEntry, deps: Deps): MenuItemConstructorOptions { |
| 36 | if (entry.type === "separator") return { type: "separator" } |
| 37 | if (entry.role) return { role: nativeRole(entry.role) } |
| 38 | |
| 39 | const item: MenuItemConstructorOptions = { |
| 40 | label: entry.label, |
| 41 | accelerator: entry.accelerator?.macos, |
| 42 | enabled: entry.enabled === "updater" ? UPDATER_ENABLED : undefined, |
| 43 | } |
| 44 | |
| 45 | if (entry.command) { |
| 46 | const command = entry.command |
| 47 | item.click = () => deps.trigger(command) |
| 48 | } |
| 49 | if (entry.action) { |
| 50 | const action = entry.action |
| 51 | item.click = () => |
| 52 | runDesktopMenuAction(BrowserWindow.getFocusedWindow(), action, { |
| 53 | checkForUpdates: deps.checkForUpdates, |
| 54 | relaunch: deps.relaunch, |
| 55 | }) |
| 56 | } |
| 57 | if (entry.href) { |
| 58 | const href = entry.href |
| 59 | item.click = () => shell.openExternal(href) |
| 60 | } |
| 61 | |
| 62 | return item |
| 63 | } |
| 64 | |
| 65 | function nativeRole(role: DesktopMenuRole) { |
| 66 | return role as NonNullable<MenuItemConstructorOptions["role"]> |
no test coverage detected