docs: Orgnize the options of BrowserWindow

This commit is contained in:
Cheng Zhao 2016-01-07 14:23:21 +08:00
Родитель 3f2b26ddb7
Коммит c0e728ab6a
1 изменённых файлов: 113 добавлений и 103 удалений

Просмотреть файл

@ -31,117 +31,127 @@ It creates a new `BrowserWindow` with native properties as set by the `options`.
### `new BrowserWindow([options])` ### `new BrowserWindow([options])`
`options` Object (optional), properties: * `options` Object
* `width` Integer - Window's width in pixels. Default is `800`.
* `height` Integer - Window's height in pixels. Default is `600`.
* `x` Integer - Window's left offset from screen. Default is to center the
window.
* `y` Integer - Window's top offset from screen. Default is to center the
window.
* `useContentSize` Boolean - The `width` and `height` would be used as web
page's size, which means the actual window's size will include window
frame's size and be slightly larger. Default is `false`.
* `center` Boolean - Show window in the center of the screen.
* `minWidth` Integer - Window's minimum width. Default is `0`.
* `minHeight` Integer - Window's minimum height. Default is `0`.
* `maxWidth` Integer - Window's maximum width. Default is no limit.
* `maxHeight` Integer - Window's maximum height. Default is no limit.
* `resizable` Boolean - Whether window is resizable. Default is `true`.
* `alwaysOnTop` Boolean - Whether the window should always stay on top of
other windows. Default is `false`.
* `fullscreen` Boolean - Whether the window should show in fullscreen. When
set to `false` the fullscreen button will be hidden or disabled on OS X.
Default is `false`.
* `skipTaskbar` Boolean - Whether to show the window in taskbar. Default is
`false`.
* `kiosk` Boolean - The kiosk mode. Default is `false`.
* `title` String - Default window title. Default is `"Electron"`.
* `icon` [NativeImage](native-image.md) - The window icon, when omitted on
Windows the executable's icon would be used as window icon.
* `show` Boolean - Whether window should be shown when created. Default is
`true`.
* `frame` Boolean - Specify `false` to create a
[Frameless Window](frameless-window.md). Default is `true`.
* `acceptFirstMouse` Boolean - Whether the web view accepts a single
mouse-down event that simultaneously activates the window. Default is `false`.
* `disableAutoHideCursor` Boolean - Whether to hide cursor when typing. Default
is `false`.
* `autoHideMenuBar` Boolean - Auto hide the menu bar unless the `Alt`
key is pressed. Default is `false`.
* `enableLargerThanScreen` Boolean - Enable the window to be resized larger
than screen. Default is `false`.
* `backgroundColor` String - Window's background color as Hexadecimal value,
like `#66CD00` or `#FFF`. This is only implemented on Linux and Windows.
Default is `#000` (black).
* `darkTheme` Boolean - Forces using dark theme for the window, only works on
some GTK+3 desktop environments. Default is `false`.
* `transparent` Boolean - Makes the window [transparent](frameless-window.md).
Default is `false`.
* `type` String - The type of window, default is normal window. See more about
this bellow.
* `titleBarStyle` String - The style of window title bar. See more about this
bellow.
* `webPreferences` Object - Settings of web page's features. See more about
this bellow.
* `width` Integer - Window's width in pixels. Default is `800`. The possible values and behaviors of `type` option are platform dependent,
* `height` Integer - Window's height in pixels. Default is `600`. supported values are:
* `x` Integer - Window's left offset from screen. Default is to center the
window. * On Linux, possible types are `desktop`, `dock`, `toolbar`, `splash`,
* `y` Integer - Window's top offset from screen. Default is to center the `notification`.
window. * On OS X, possible types are `desktop`, `textured`.
* `useContentSize` Boolean - The `width` and `height` would be used as web * The `textured` type adds metal gradient appearance
page's size, which means the actual window's size will include window (`NSTexturedBackgroundWindowMask`).
frame's size and be slightly larger. Default is `false`. * The `desktop` type places the window at the desktop background window level
* `center` Boolean - Show window in the center of the screen.
* `minWidth` Integer - Window's minimum width. Default is `0`.
* `minHeight` Integer - Window's minimum height. Default is `0`.
* `maxWidth` Integer - Window's maximum width. Default is no limit.
* `maxHeight` Integer - Window's maximum height. Default is no limit.
* `resizable` Boolean - Whether window is resizable. Default is `true`.
* `alwaysOnTop` Boolean - Whether the window should always stay on top of
other windows. Default is `false`.
* `fullscreen` Boolean - Whether the window should show in fullscreen. When
set to `false` the fullscreen button will be hidden or disabled on OS X.
Default is `false`.
* `skipTaskbar` Boolean - Whether to show the window in taskbar. Default is
`false`.
* `kiosk` Boolean - The kiosk mode. Default is `false`.
* `title` String - Default window title. Default is `"Electron"`.
* `icon` [NativeImage](native-image.md) - The window icon, when omitted on
Windows the executable's icon would be used as window icon.
* `show` Boolean - Whether window should be shown when created. Default is
`true`.
* `frame` Boolean - Specify `false` to create a
[Frameless Window](frameless-window.md). Default is `true`.
* `acceptFirstMouse` Boolean - Whether the web view accepts a single
mouse-down event that simultaneously activates the window. Default is `false`.
* `disableAutoHideCursor` Boolean - Whether to hide cursor when typing. Default
is `false`.
* `autoHideMenuBar` Boolean - Auto hide the menu bar unless the `Alt`
key is pressed. Default is `false`.
* `enableLargerThanScreen` Boolean - Enable the window to be resized larger
than screen. Default is `false`.
* `backgroundColor` String - Window's background color as Hexadecimal value,
like `#66CD00` or `#FFF`. This is only implemented on Linux and Windows.
Default is `#000` (black).
* `darkTheme` Boolean - Forces using dark theme for the window, only works on
some GTK+3 desktop environments. Default is `false`.
* `transparent` Boolean - Makes the window [transparent](frameless-window.md).
Default is `false`.
* `type` String - Specifies the type of the window, which applies
additional platform-specific properties. By default it's undefined and you'll
get a regular app window. Supported values:
* On Linux, possible types are `desktop`, `dock`, `toolbar`, `splash`,
`notification`.
* On OS X, possible types are `desktop`, `textured`. The `textured` type adds
metal gradient appearance (`NSTexturedBackgroundWindowMask`). The `desktop`
type places the window at the desktop background window level
(`kCGDesktopWindowLevel - 1`). Note that desktop window will not receive (`kCGDesktopWindowLevel - 1`). Note that desktop window will not receive
focus, keyboard or mouse events, but you can use `globalShortcut` to receive focus, keyboard or mouse events, but you can use `globalShortcut` to receive
input sparingly. input sparingly.
* `titleBarStyle` String, OS X - specifies the style of window title bar.
This option is supported on OS X 10.10 Yosemite and newer. There are three The `titleBarStyle` option is only supported on OS X 10.10 Yosemite and newer.
possible values: Possible values are:
* `default` or not specified, results in the standard gray opaque Mac title
* `default` or not specified, results in the standard gray opaque Mac title
bar. bar.
* `hidden` results in a hidden title bar and a full size content window, yet * `hidden` results in a hidden title bar and a full size content window, yet
the title bar still has the standard window controls ("traffic lights") in the title bar still has the standard window controls ("traffic lights") in
the top left. the top left.
* `hidden-inset` results in a hidden title bar with an alternative look * `hidden-inset` results in a hidden title bar with an alternative look
where the traffic light buttons are slightly more inset from the window edge. where the traffic light buttons are slightly more inset from the window edge.
* `webPreferences` Object - Settings of web page's features, properties:
* `nodeIntegration` Boolean - Whether node integration is enabled. Default The `webPreferences` option is an object that can have following properties:
is `true`.
* `preload` String - Specifies a script that will be loaded before other * `nodeIntegration` Boolean - Whether node integration is enabled. Default
scripts run in the page. This script will always have access to node APIs is `true`.
no matter whether node integration is turned on or off. The value should * `preload` String - Specifies a script that will be loaded before other
be the absolute file path to the script. scripts run in the page. This script will always have access to node APIs
When node integration is turned off, the preload script can reintroduce no matter whether node integration is turned on or off. The value should
Node global symbols back to the global scope. See example be the absolute file path to the script.
[here](process.md#event-loaded). When node integration is turned off, the preload script can reintroduce
* `partition` String - Sets the session used by the page. If `partition` Node global symbols back to the global scope. See example
starts with `persist:`, the page will use a persistent session available to [here](process.md#event-loaded).
all pages in the app with the same `partition`. if there is no `persist:` * `partition` String - Sets the session used by the page. If `partition`
prefix, the page will use an in-memory session. By assigning the same starts with `persist:`, the page will use a persistent session available to
`partition`, multiple pages can share the same session. If the `partition` all pages in the app with the same `partition`. if there is no `persist:`
is unset then default session of the app will be used. prefix, the page will use an in-memory session. By assigning the same
* `zoomFactor` Number - The default zoom factor of the page, `3.0` represents `partition`, multiple pages can share the same session. If the `partition`
`300%`. Default is `1.0`. is unset then default session of the app will be used.
* `javascript` Boolean - Enables JavaScript support. Default is `true`. * `zoomFactor` Number - The default zoom factor of the page, `3.0` represents
* `webSecurity` Boolean - When setting `false`, it will disable the `300%`. Default is `1.0`.
same-origin policy (Usually using testing websites by people), and set * `javascript` Boolean - Enables JavaScript support. Default is `true`.
`allowDisplayingInsecureContent` and `allowRunningInsecureContent` to * `webSecurity` Boolean - When setting `false`, it will disable the
`true` if these two options are not set by user. Default is `true`. same-origin policy (Usually using testing websites by people), and set
* `allowDisplayingInsecureContent` Boolean - Allow an https page to display `allowDisplayingInsecureContent` and `allowRunningInsecureContent` to
content like images from http URLs. Default is `false`. `true` if these two options are not set by user. Default is `true`.
* `allowRunningInsecureContent` Boolean - Allow a https page to run * `allowDisplayingInsecureContent` Boolean - Allow an https page to display
JavaScript, CSS or plugins from http URLs. Default is `false`. content like images from http URLs. Default is `false`.
* `images` Boolean - Enables image support. Default is `true`. * `allowRunningInsecureContent` Boolean - Allow a https page to run
* `textAreasAreResizable` Boolean - Make TextArea elements resizable. Default JavaScript, CSS or plugins from http URLs. Default is `false`.
is `true`. * `images` Boolean - Enables image support. Default is `true`.
* `webgl` Boolean - Enables WebGL support. Default is `true`. * `textAreasAreResizable` Boolean - Make TextArea elements resizable. Default
* `webaudio` Boolean - Enables WebAudio support. Default is `true`. is `true`.
* `plugins` Boolean - Whether plugins should be enabled. Default is `false`. * `webgl` Boolean - Enables WebGL support. Default is `true`.
* `experimentalFeatures` Boolean - Enables Chromium's experimental features. * `webaudio` Boolean - Enables WebAudio support. Default is `true`.
Default is `false`. * `plugins` Boolean - Whether plugins should be enabled. Default is `false`.
* `experimentalCanvasFeatures` Boolean - Enables Chromium's experimental * `experimentalFeatures` Boolean - Enables Chromium's experimental features.
canvas features. Default is `false`. Default is `false`.
* `directWrite` Boolean - Enables DirectWrite font rendering system on * `experimentalCanvasFeatures` Boolean - Enables Chromium's experimental
Windows. Default is `true`. canvas features. Default is `false`.
* `blinkFeatures` String - A list of feature strings separated by `,`, like * `directWrite` Boolean - Enables DirectWrite font rendering system on
`CSSVariables,KeyboardEventKey`. The full list of supported feature strings Windows. Default is `true`.
can be found in the [setFeatureEnabledFromString][blink-feature-string] * `blinkFeatures` String - A list of feature strings separated by `,`, like
function. `CSSVariables,KeyboardEventKey`. The full list of supported feature strings
can be found in the [setFeatureEnabledFromString][blink-feature-string]
function.
## Events ## Events