refactor: convert more files to typescript (#16820)
This commit is contained in:
parent
cfbdc40814
commit
01c442de64
16 changed files with 169 additions and 90 deletions
54
lib/browser/default-menu.ts
Normal file
54
lib/browser/default-menu.ts
Normal file
|
@ -0,0 +1,54 @@
|
|||
import { shell, Menu } from 'electron'
|
||||
|
||||
const v8Util = process.atomBinding('v8_util')
|
||||
|
||||
const isMac = process.platform === 'darwin'
|
||||
|
||||
export const setDefaultApplicationMenu = () => {
|
||||
if (v8Util.getHiddenValue<boolean>(global, 'applicationMenuSet')) return
|
||||
|
||||
const helpMenu: Electron.MenuItemConstructorOptions = {
|
||||
role: 'help',
|
||||
submenu: [
|
||||
{
|
||||
label: 'Learn More',
|
||||
click () {
|
||||
shell.openExternalSync('https://electronjs.org')
|
||||
}
|
||||
},
|
||||
{
|
||||
label: 'Documentation',
|
||||
click () {
|
||||
shell.openExternalSync(
|
||||
`https://github.com/electron/electron/tree/v${process.versions.electron}/docs#readme`
|
||||
)
|
||||
}
|
||||
},
|
||||
{
|
||||
label: 'Community Discussions',
|
||||
click () {
|
||||
shell.openExternalSync('https://discuss.atom.io/c/electron')
|
||||
}
|
||||
},
|
||||
{
|
||||
label: 'Search Issues',
|
||||
click () {
|
||||
shell.openExternalSync('https://github.com/electron/electron/issues')
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
const macAppMenu: Electron.MenuItemConstructorOptions = { role: 'appMenu' }
|
||||
const template: Electron.MenuItemConstructorOptions[] = [
|
||||
...(isMac ? [macAppMenu] : []),
|
||||
{ role: 'fileMenu' },
|
||||
{ role: 'editMenu' },
|
||||
{ role: 'viewMenu' },
|
||||
{ role: 'windowMenu' },
|
||||
helpMenu
|
||||
]
|
||||
|
||||
const menu = Menu.buildFromTemplate(template)
|
||||
Menu.setApplicationMenu(menu)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue