electron-util 常用包
最后更新于:2022-04-02 03:35:18
[TOC]
> [github](https://github.com/sindresorhus/electron-util#runjscode-window)
## 概述
```
const {is} = require('electron-util');
console.log(is.macos && is.main);
//=> true
```
## 接口
* [`api`](https://github.com/sindresorhus/electron-util#api-1)
* [`is`](https://github.com/sindresorhus/electron-util#is)
* [`electronVersion`](https://github.com/sindresorhus/electron-util#electronversion)
* [`chromeVersion`](https://github.com/sindresorhus/electron-util#chromeversion)
* [`platform()`](https://github.com/sindresorhus/electron-util#platformchoices)
* [`activeWindow()`](https://github.com/sindresorhus/electron-util#activewindow)
* [`runJS()`](https://github.com/sindresorhus/electron-util#runjscode-window)
* [`fixPathForAsarUnpack()`](https://github.com/sindresorhus/electron-util#fixpathforasarunpackpath)
* [`enforceMacOSAppLocation()`](https://github.com/sindresorhus/electron-util#enforcemacosapplocation-macos)
* [`menuBarHeight()`](https://github.com/sindresorhus/electron-util#menubarheight-macos)
* [`getWindowBoundsCentered()`](https://github.com/sindresorhus/electron-util#getwindowboundscenteredoptions)
* [`setWindowBounds()`](https://github.com/sindresorhus/electron-util#setwindowboundsbounds-options)
* [`centerWindow()`](https://github.com/sindresorhus/electron-util#centerwindowoptions)
* [`disableZoom()`](https://github.com/sindresorhus/electron-util#disablezoomwindow)
* [`appLaunchTimestamp`](https://github.com/sindresorhus/electron-util#applaunchtimestamp)
* [`isFirstAppLaunch()`](https://github.com/sindresorhus/electron-util#isfirstapplaunch)
* [`darkMode`](https://github.com/sindresorhus/electron-util#darkmode)
* [`setContentSecurityPolicy`](https://github.com/sindresorhus/electron-util#setcontentsecuritypolicypolicy-options)
* [`openNewGitHubIssue()`](https://github.com/sindresorhus/electron-util#opennewgithubissueoptions)
* [`openUrlMenuItem()`](https://github.com/sindresorhus/electron-util#openurlmenuitemoptions)
* [`showAboutWindow()`](https://github.com/sindresorhus/electron-util#showaboutwindowoptions-linux-windows)
* [`aboutMenuItem()`](https://github.com/sindresorhus/electron-util#aboutmenuitemoptions-linux-windows)
* [`debugInfo()`](https://github.com/sindresorhus/electron-util#debuginfo)
* [`appMenu()`](https://github.com/sindresorhus/electron-util#appmenumenuitems-macos)
### api 在主要和渲染器过程中访问Electron API,而无需关心您所在的那个
`api.app.quit();
`
## is 判断
* `macos`\- Running on macOS
* `linux`\- Running on Linux
* `windows`\- Running on Windows
* `main`\- Running on the[main process](https://electronjs.org/docs/tutorial/quick-start/#main-process)
* `renderer`\- Running on the[renderer process](https://electronjs.org/docs/tutorial/quick-start/#renderer-process)
* `development`\- Running in development, not in production
* `usingAsar`\- The app is using[ASAR](https://electronjs.org/docs/tutorial/application-packaging/)
* `macAppStore`\- The app is an Mac App Store build
* `windowsStore`\- The app is a Windows Store AppX build
';