chore: update ref to docs (🤖)
This commit is contained in:
Родитель
fb05159bea
Коммит
fd148b5c38
|
@ -135,9 +135,8 @@ Emitted when the user wants to open a URL with the application. Your application
|
|||
set `NSPrincipalClass` to `AtomApplication`.
|
||||
|
||||
As with the `open-file` event, be sure to register a listener for the `open-url`
|
||||
event early in your application startup to detect if the the application being
|
||||
is being opened to handle a URL. If you register the listener in response to a
|
||||
`ready` event, you'll miss URLs that trigger the launch of your application.
|
||||
event early in your application startup to detect if the application is being opened to handle a URL.
|
||||
If you register the listener in response to a `ready` event, you'll miss URLs that trigger the launch of your application.
|
||||
|
||||
### Event: 'activate' _macOS_
|
||||
|
||||
|
@ -1272,6 +1271,9 @@ On macOS, it shows on the dock icon. On Linux, it only works for Unity launcher.
|
|||
**Note:** Unity launcher requires a `.desktop` file to work. For more information,
|
||||
please read the [Unity integration documentation][unity-requirement].
|
||||
|
||||
**Note:** On macOS, you need to ensure that your application has the permission
|
||||
to display notifications for this method to work.
|
||||
|
||||
### `app.getBadgeCount()` _Linux_ _macOS_
|
||||
|
||||
Returns `Integer` - The current value displayed in the counter badge.
|
||||
|
|
|
@ -108,6 +108,7 @@ app.whenReady().then(() => {
|
|||
* `monospace` string (optional) - Defaults to `Courier New`.
|
||||
* `cursive` string (optional) - Defaults to `Script`.
|
||||
* `fantasy` string (optional) - Defaults to `Impact`.
|
||||
* `math` string (optional) - Defaults to `Latin Modern Math`.
|
||||
* `defaultFontSize` Integer (optional) - Defaults to `16`.
|
||||
* `defaultMonospaceFontSize` Integer (optional) - Defaults to `13`.
|
||||
* `minimumFontSize` Integer (optional) - Defaults to `0`.
|
||||
|
|
|
@ -264,12 +264,9 @@ It creates a new `BrowserWindow` with native properties as set by the `options`.
|
|||
Windows, which adds standard window frame. Setting it to `false` will remove
|
||||
window shadow and window animations. Default is `true`.
|
||||
* `vibrancy` string (optional) _macOS_ - Add a type of vibrancy effect to
|
||||
the window, only on macOS. Can be `appearance-based`, `light`, `dark`,
|
||||
`titlebar`, `selection`, `menu`, `popover`, `sidebar`, `medium-light`,
|
||||
`ultra-dark`, `header`, `sheet`, `window`, `hud`, `fullscreen-ui`,
|
||||
`tooltip`, `content`, `under-window`, or `under-page`. Please note that
|
||||
`appearance-based`, `light`, `dark`, `medium-light`, and `ultra-dark` are
|
||||
deprecated and have been removed in macOS Catalina (10.15).
|
||||
the window, only on macOS. Can be `appearance-based`, `titlebar`, `selection`,
|
||||
`menu`, `popover`, `sidebar`, `header`, `sheet`, `window`, `hud`, `fullscreen-ui`,
|
||||
`tooltip`, `content`, `under-window`, or `under-page`.
|
||||
* `backgroundMaterial` string (optional) _Windows_ - Set the window's
|
||||
system-drawn background material, including behind the non-client area.
|
||||
Can be `auto`, `none`, `mica`, `acrylic` or `tabbed`. See [win.setBackgroundMaterial](latest/api/browser-window.md#winsetbackgroundmaterialmaterial-windows) for more information.
|
||||
|
@ -352,6 +349,7 @@ It creates a new `BrowserWindow` with native properties as set by the `options`.
|
|||
* `monospace` string (optional) - Defaults to `Courier New`.
|
||||
* `cursive` string (optional) - Defaults to `Script`.
|
||||
* `fantasy` string (optional) - Defaults to `Impact`.
|
||||
* `math` string (optional) - Defaults to `Latin Modern Math`.
|
||||
* `defaultFontSize` Integer (optional) - Defaults to `16`.
|
||||
* `defaultMonospaceFontSize` Integer (optional) - Defaults to `13`.
|
||||
* `minimumFontSize` Integer (optional) - Defaults to `0`.
|
||||
|
@ -812,6 +810,10 @@ events.
|
|||
|
||||
A `Integer` property representing the unique ID of the window. Each ID is unique among all `BrowserWindow` instances of the entire Electron application.
|
||||
|
||||
#### `win.tabbingIdentifier` _macOS_ _Readonly_
|
||||
|
||||
A `string` (optional) property that is equal to the `tabbingIdentifier` passed to the `BrowserWindow` constructor or `undefined` if none was set.
|
||||
|
||||
#### `win.autoHideMenuBar`
|
||||
|
||||
A `boolean` property that determines whether the window menu bar should hide itself automatically. Once set, the menu bar will only show when users press the single `Alt` key.
|
||||
|
@ -1842,6 +1844,10 @@ tabs in the window.
|
|||
Selects the next tab when native tabs are enabled and there are other
|
||||
tabs in the window.
|
||||
|
||||
#### `win.showAllTabs()` _macOS_
|
||||
|
||||
Shows or hides the tab overview when native tabs are enabled.
|
||||
|
||||
#### `win.mergeAllWindows()` _macOS_
|
||||
|
||||
Merges all windows into one window with multiple tabs when native tabs
|
||||
|
@ -1865,16 +1871,12 @@ Adds a window as a tab on this window, after the tab for the window instance.
|
|||
|
||||
#### `win.setVibrancy(type)` _macOS_
|
||||
|
||||
* `type` string | null - Can be `appearance-based`, `light`, `dark`, `titlebar`,
|
||||
`selection`, `menu`, `popover`, `sidebar`, `medium-light`, `ultra-dark`, `header`, `sheet`, `window`, `hud`, `fullscreen-ui`, `tooltip`, `content`, `under-window`, or `under-page`. See
|
||||
* `type` string | null - Can be `titlebar`, `selection`, `menu`, `popover`, `sidebar`, `header`, `sheet`, `window`, `hud`, `fullscreen-ui`, `tooltip`, `content`, `under-window`, or `under-page`. See
|
||||
the [macOS documentation][vibrancy-docs] for more details.
|
||||
|
||||
Adds a vibrancy effect to the browser window. Passing `null` or an empty string
|
||||
will remove the vibrancy effect on the window.
|
||||
|
||||
Note that `appearance-based`, `light`, `dark`, `medium-light`, and `ultra-dark` have been
|
||||
deprecated and will be removed in an upcoming version of macOS.
|
||||
|
||||
#### `win.setBackgroundMaterial(material)` _Windows_
|
||||
|
||||
* `material` string
|
||||
|
@ -1962,8 +1964,8 @@ Throws an error if `browserView` is not attached to `win`.
|
|||
|
||||
#### `win.getBrowserViews()` _Experimental_
|
||||
|
||||
Returns `BrowserView[]` - an array of all BrowserViews that have been attached
|
||||
with `addBrowserView` or `setBrowserView`.
|
||||
Returns `BrowserView[]` - a sorted by z-index array of all BrowserViews that have been attached
|
||||
with `addBrowserView` or `setBrowserView`. The top-most BrowserView is the last element of the array.
|
||||
|
||||
**Note:** The BrowserView API is currently experimental and may change or be
|
||||
removed in future Electron releases.
|
||||
|
|
|
@ -29,7 +29,7 @@ session.defaultSession.cookies.get({})
|
|||
})
|
||||
|
||||
// Query all cookies associated with a specific url.
|
||||
session.defaultSession.cookies.get({ url: 'http://www.github.com' })
|
||||
session.defaultSession.cookies.get({ url: 'https://www.github.com' })
|
||||
.then((cookies) => {
|
||||
console.log(cookies)
|
||||
}).catch((error) => {
|
||||
|
@ -38,7 +38,7 @@ session.defaultSession.cookies.get({ url: 'http://www.github.com' })
|
|||
|
||||
// Set a cookie with the given cookie data;
|
||||
// may overwrite equivalent cookies if they exist.
|
||||
const cookie = { url: 'http://www.github.com', name: 'dummy_name', value: 'dummy' }
|
||||
const cookie = { url: 'https://www.github.com', name: 'dummy_name', value: 'dummy' }
|
||||
session.defaultSession.cookies.set(cookie)
|
||||
.then(() => {
|
||||
// success
|
||||
|
|
|
@ -192,7 +192,7 @@ ipcMain.on('port', (e, msg) => {
|
|||
For more information on using `MessagePort` and `MessageChannel`, see the [MDN
|
||||
documentation](https://developer.mozilla.org/en-US/docs/Web/API/MessageChannel).
|
||||
|
||||
### `ipcRenderer.sendTo(webContentsId, channel, ...args)`
|
||||
### `ipcRenderer.sendTo(webContentsId, channel, ...args)` _Deprecated_
|
||||
|
||||
* `webContentsId` number
|
||||
* `channel` string
|
||||
|
|
|
@ -21,7 +21,7 @@ See [`Menu`](latest/api/menu.md) for examples.
|
|||
* `menuItem` MenuItem
|
||||
* `browserWindow` [BrowserWindow](latest/api/browser-window.md) | undefined - This will not be defined if no window is open.
|
||||
* `event` [KeyboardEvent](latest/api/structures/keyboard-event.md)
|
||||
* `role` string (optional) - Can be `undo`, `redo`, `cut`, `copy`, `paste`, `pasteAndMatchStyle`, `delete`, `selectAll`, `reload`, `forceReload`, `toggleDevTools`, `resetZoom`, `zoomIn`, `zoomOut`, `toggleSpellChecker`, `togglefullscreen`, `window`, `minimize`, `close`, `help`, `about`, `services`, `hide`, `hideOthers`, `unhide`, `quit`, `showSubstitutions`, `toggleSmartQuotes`, `toggleSmartDashes`, `toggleTextReplacement`, `startSpeaking`, `stopSpeaking`, `zoom`, `front`, `appMenu`, `fileMenu`, `editMenu`, `viewMenu`, `shareMenu`, `recentDocuments`, `toggleTabBar`, `selectNextTab`, `selectPreviousTab`, `mergeAllWindows`, `clearRecentDocuments`, `moveTabToNewWindow` or `windowMenu` - Define the action of the menu item, when specified the
|
||||
* `role` string (optional) - Can be `undo`, `redo`, `cut`, `copy`, `paste`, `pasteAndMatchStyle`, `delete`, `selectAll`, `reload`, `forceReload`, `toggleDevTools`, `resetZoom`, `zoomIn`, `zoomOut`, `toggleSpellChecker`, `togglefullscreen`, `window`, `minimize`, `close`, `help`, `about`, `services`, `hide`, `hideOthers`, `unhide`, `quit`, `showSubstitutions`, `toggleSmartQuotes`, `toggleSmartDashes`, `toggleTextReplacement`, `startSpeaking`, `stopSpeaking`, `zoom`, `front`, `appMenu`, `fileMenu`, `editMenu`, `viewMenu`, `shareMenu`, `recentDocuments`, `toggleTabBar`, `selectNextTab`, `selectPreviousTab`, `showAllTabs`, `mergeAllWindows`, `clearRecentDocuments`, `moveTabToNewWindow` or `windowMenu` - Define the action of the menu item, when specified the
|
||||
`click` property will be ignored. See [roles](#roles).
|
||||
* `type` string (optional) - Can be `normal`, `separator`, `submenu`, `checkbox` or
|
||||
`radio`.
|
||||
|
@ -118,6 +118,7 @@ The following additional roles are available on _macOS_:
|
|||
* `toggleTabBar` - Map to the `toggleTabBar` action.
|
||||
* `selectNextTab` - Map to the `selectNextTab` action.
|
||||
* `selectPreviousTab` - Map to the `selectPreviousTab` action.
|
||||
* `showAllTabs` - Map to the `showAllTabs` action.
|
||||
* `mergeAllWindows` - Map to the `mergeAllWindows` action.
|
||||
* `moveTabToNewWindow` - Map to the `moveTabToNewWindow` action.
|
||||
* `window` - The submenu is a "Window" menu.
|
||||
|
@ -166,7 +167,7 @@ A `string` indicating the type of the item. Can be `normal`, `separator`, `subme
|
|||
|
||||
#### `menuItem.role`
|
||||
|
||||
A `string` (optional) indicating the item's role, if set. Can be `undo`, `redo`, `cut`, `copy`, `paste`, `pasteAndMatchStyle`, `delete`, `selectAll`, `reload`, `forceReload`, `toggleDevTools`, `resetZoom`, `zoomIn`, `zoomOut`, `toggleSpellChecker`, `togglefullscreen`, `window`, `minimize`, `close`, `help`, `about`, `services`, `hide`, `hideOthers`, `unhide`, `quit`, `startSpeaking`, `stopSpeaking`, `zoom`, `front`, `appMenu`, `fileMenu`, `editMenu`, `viewMenu`, `shareMenu`, `recentDocuments`, `toggleTabBar`, `selectNextTab`, `selectPreviousTab`, `mergeAllWindows`, `clearRecentDocuments`, `moveTabToNewWindow` or `windowMenu`
|
||||
A `string` (optional) indicating the item's role, if set. Can be `undo`, `redo`, `cut`, `copy`, `paste`, `pasteAndMatchStyle`, `delete`, `selectAll`, `reload`, `forceReload`, `toggleDevTools`, `resetZoom`, `zoomIn`, `zoomOut`, `toggleSpellChecker`, `togglefullscreen`, `window`, `minimize`, `close`, `help`, `about`, `services`, `hide`, `hideOthers`, `unhide`, `quit`, `startSpeaking`, `stopSpeaking`, `zoom`, `front`, `appMenu`, `fileMenu`, `editMenu`, `viewMenu`, `shareMenu`, `recentDocuments`, `toggleTabBar`, `selectNextTab`, `selectPreviousTab`, `showAllTabs`, `mergeAllWindows`, `clearRecentDocuments`, `moveTabToNewWindow` or `windowMenu`
|
||||
|
||||
#### `menuItem.accelerator`
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ property of [`WebContents`](latest/api/web-contents.md), or from the `session` m
|
|||
const { BrowserWindow } = require('electron')
|
||||
|
||||
const win = new BrowserWindow({ width: 800, height: 600 })
|
||||
win.loadURL('http://github.com')
|
||||
win.loadURL('https://github.com')
|
||||
|
||||
const ses = win.webContents.session
|
||||
console.log(ses.getUserAgent())
|
||||
|
|
|
@ -111,12 +111,9 @@ hide_title: false
|
|||
Windows, which adds standard window frame. Setting it to `false` will remove
|
||||
window shadow and window animations. Default is `true`.
|
||||
* `vibrancy` string (optional) _macOS_ - Add a type of vibrancy effect to
|
||||
the window, only on macOS. Can be `appearance-based`, `light`, `dark`,
|
||||
`titlebar`, `selection`, `menu`, `popover`, `sidebar`, `medium-light`,
|
||||
`ultra-dark`, `header`, `sheet`, `window`, `hud`, `fullscreen-ui`,
|
||||
`tooltip`, `content`, `under-window`, or `under-page`. Please note that
|
||||
`appearance-based`, `light`, `dark`, `medium-light`, and `ultra-dark` are
|
||||
deprecated and have been removed in macOS Catalina (10.15).
|
||||
the window, only on macOS. Can be `appearance-based`, `titlebar`, `selection`,
|
||||
`menu`, `popover`, `sidebar`, `header`, `sheet`, `window`, `hud`, `fullscreen-ui`,
|
||||
`tooltip`, `content`, `under-window`, or `under-page`.
|
||||
* `backgroundMaterial` string (optional) _Windows_ - Set the window's
|
||||
system-drawn background material, including behind the non-client area.
|
||||
Can be `auto`, `none`, `mica`, `acrylic` or `tabbed`. See [win.setBackgroundMaterial](latest/api/browser-window.md#winsetbackgroundmaterialmaterial-windows) for more information.
|
||||
|
@ -199,6 +196,7 @@ hide_title: false
|
|||
* `monospace` string (optional) - Defaults to `Courier New`.
|
||||
* `cursive` string (optional) - Defaults to `Script`.
|
||||
* `fantasy` string (optional) - Defaults to `Impact`.
|
||||
* `math` string (optional) - Defaults to `Latin Modern Math`.
|
||||
* `defaultFontSize` Integer (optional) - Defaults to `16`.
|
||||
* `defaultMonospaceFontSize` Integer (optional) - Defaults to `13`.
|
||||
* `minimumFontSize` Integer (optional) - Defaults to `0`.
|
||||
|
|
|
@ -8,9 +8,9 @@ hide_title: false
|
|||
# IpcRendererEvent Object extends `Event`
|
||||
|
||||
* `sender` [IpcRenderer](latest/api/ipc-renderer.md) - The `IpcRenderer` instance that emitted the event originally
|
||||
* `senderId` Integer - The `webContents.id` that sent the message, you can call `event.sender.sendTo(event.senderId, ...)` to reply to the message, see [ipcRenderer.sendTo][ipc-renderer-sendto] for more information. This only applies to messages sent from a different renderer. Messages sent directly from the main process set `event.senderId` to `0`.
|
||||
* `senderIsMainFrame` boolean (optional) - Whether the message sent via [ipcRenderer.sendTo][ipc-renderer-sendto] was sent by the main frame. This is relevant when `nodeIntegrationInSubFrames` is enabled in the originating `webContents`.
|
||||
* `senderId` Integer _Deprecated_ - The `webContents.id` that sent the message, you can call `event.sender.sendTo(event.senderId, ...)` to reply to the message, see [ipcRenderer.sendTo][ipc-renderer-sendto] for more information. This only applies to messages sent from a different renderer. Messages sent directly from the main process set `event.senderId` to `0`.
|
||||
* `senderIsMainFrame` boolean (optional) _Deprecated_ - Whether the message sent via [ipcRenderer.sendTo][ipc-renderer-sendto] was sent by the main frame. This is relevant when `nodeIntegrationInSubFrames` is enabled in the originating `webContents`.
|
||||
* `ports` [MessagePort][][] - A list of MessagePorts that were transferred with this message
|
||||
|
||||
[ipc-renderer-sendto]: latest/api/ipc-renderer.md#ipcrenderersendtowebcontentsid-channel-args
|
||||
[ipc-renderer-sendto]: latest/api/ipc-renderer.md#ipcrenderersendtowebcontentsid-channel-args-deprecated
|
||||
[MessagePort]: https://developer.mozilla.org/en-US/docs/Web/API/MessagePort
|
||||
|
|
|
@ -10,8 +10,6 @@ hide_title: false
|
|||
* `productIdentifier` string - The string that identifies the product to the Apple App Store.
|
||||
* `localizedDescription` string - A description of the product.
|
||||
* `localizedTitle` string - The name of the product.
|
||||
* `contentVersion` string - A string that identifies the version of the content.
|
||||
* `contentLengths` number[] - The total size of the content, in bytes.
|
||||
* `price` number - The cost of the product in the local currency.
|
||||
* `formattedPrice` string - The locale formatted price of the product.
|
||||
* `currencyCode` string - 3 character code presenting a product's currency based on the ISO 4217 standard.
|
||||
|
|
|
@ -74,6 +74,7 @@ hide_title: false
|
|||
* `monospace` string (optional) - Defaults to `Courier New`.
|
||||
* `cursive` string (optional) - Defaults to `Script`.
|
||||
* `fantasy` string (optional) - Defaults to `Impact`.
|
||||
* `math` string (optional) - Defaults to `Latin Modern Math`.
|
||||
* `defaultFontSize` Integer (optional) - Defaults to `16`.
|
||||
* `defaultMonospaceFontSize` Integer (optional) - Defaults to `13`.
|
||||
* `minimumFontSize` Integer (optional) - Defaults to `0`.
|
||||
|
|
|
@ -34,24 +34,6 @@ Returns:
|
|||
|
||||
* `event` Event
|
||||
|
||||
### Event: 'inverted-color-scheme-changed' _Windows_ _Deprecated_
|
||||
|
||||
Returns:
|
||||
|
||||
* `event` Event
|
||||
* `invertedColorScheme` boolean - `true` if an inverted color scheme (a high contrast color scheme with light text and dark backgrounds) is being used, `false` otherwise.
|
||||
|
||||
**Deprecated:** Should use the new [`updated`](latest/api/native-theme.md#event-updated) event on the `nativeTheme` module.
|
||||
|
||||
### Event: 'high-contrast-color-scheme-changed' _Windows_ _Deprecated_
|
||||
|
||||
Returns:
|
||||
|
||||
* `event` Event
|
||||
* `highContrastColorScheme` boolean - `true` if a high contrast theme is being used, `false` otherwise.
|
||||
|
||||
**Deprecated:** Should use the new [`updated`](latest/api/native-theme.md#event-updated) event on the `nativeTheme` module.
|
||||
|
||||
## Methods
|
||||
|
||||
### `systemPreferences.isSwipeTrackingFromScrollEventsEnabled()` _macOS_
|
||||
|
@ -298,7 +280,6 @@ This API is only available on macOS 10.14 Mojave or newer.
|
|||
* `window-frame` - Window frame.
|
||||
* `window-text` - Text in windows.
|
||||
* On **macOS**
|
||||
* `alternate-selected-control-text` - The text on a selected surface in a list or table. _Deprecated_
|
||||
* `control-background` - The background of a large interface element, such as a browser or table.
|
||||
* `control` - The surface of a control.
|
||||
* `control-text` -The text of a control that isn’t disabled.
|
||||
|
@ -364,21 +345,6 @@ Returns `string` - Can be `dark`, `light` or `unknown`.
|
|||
Gets the macOS appearance setting that is currently applied to your application,
|
||||
maps to [NSApplication.effectiveAppearance](https://developer.apple.com/documentation/appkit/nsapplication/2967171-effectiveappearance?language=objc)
|
||||
|
||||
### `systemPreferences.getAppLevelAppearance()` _macOS_ _Deprecated_
|
||||
|
||||
Returns `string` | `null` - Can be `dark`, `light` or `unknown`.
|
||||
|
||||
Gets the macOS appearance setting that you have declared you want for
|
||||
your application, maps to [NSApplication.appearance](https://developer.apple.com/documentation/appkit/nsapplication/2967170-appearance?language=objc).
|
||||
You can use the `setAppLevelAppearance` API to set this value.
|
||||
|
||||
### `systemPreferences.setAppLevelAppearance(appearance)` _macOS_ _Deprecated_
|
||||
|
||||
* `appearance` string | null - Can be `dark` or `light`
|
||||
|
||||
Sets the appearance setting for your application, this should override the
|
||||
system default and override the value of `getEffectiveAppearance`.
|
||||
|
||||
### `systemPreferences.canPromptTouchID()` _macOS_
|
||||
|
||||
Returns `boolean` - whether or not this device has the ability to use Touch ID.
|
||||
|
@ -446,16 +412,6 @@ Returns an object with system animation settings.
|
|||
|
||||
A `boolean` property which determines whether the app avoids using semitransparent backgrounds. This maps to [NSWorkspace.accessibilityDisplayShouldReduceTransparency](https://developer.apple.com/documentation/appkit/nsworkspace/1533006-accessibilitydisplayshouldreduce)
|
||||
|
||||
### `systemPreferences.appLevelAppearance` _macOS_ _Deprecated_
|
||||
|
||||
A `string` property that can be `dark`, `light` or `unknown`. It determines the macOS appearance setting for
|
||||
your application. This maps to values in: [NSApplication.appearance](https://developer.apple.com/documentation/appkit/nsapplication/2967170-appearance?language=objc). Setting this will override the
|
||||
system default as well as the value of `getEffectiveAppearance`.
|
||||
|
||||
Possible values that can be set are `dark` and `light`, and possible return values are `dark`, `light`, and `unknown`.
|
||||
|
||||
This property is only available on macOS 10.14 Mojave or newer.
|
||||
|
||||
### `systemPreferences.effectiveAppearance` _macOS_ _Readonly_
|
||||
|
||||
A `string` property that can be `dark`, `light` or `unknown`.
|
||||
|
|
|
@ -20,7 +20,7 @@ the [`BrowserWindow`](latest/api/browser-window.md) object. An example of access
|
|||
const { BrowserWindow } = require('electron')
|
||||
|
||||
const win = new BrowserWindow({ width: 800, height: 1500 })
|
||||
win.loadURL('http://github.com')
|
||||
win.loadURL('https://github.com')
|
||||
|
||||
const contents = win.webContents
|
||||
console.log(contents)
|
||||
|
@ -891,7 +891,7 @@ const win = new BrowserWindow({ webPreferences: { offscreen: true } })
|
|||
win.webContents.on('paint', (event, dirty, image) => {
|
||||
// updateBitmap(dirty, image.getBitmap())
|
||||
})
|
||||
win.loadURL('http://github.com')
|
||||
win.loadURL('https://github.com')
|
||||
```
|
||||
|
||||
#### Event: 'devtools-reload-page'
|
||||
|
@ -1069,7 +1069,7 @@ Returns `string` - The URL of the current web page.
|
|||
```javascript
|
||||
const { BrowserWindow } = require('electron')
|
||||
const win = new BrowserWindow({ width: 800, height: 600 })
|
||||
win.loadURL('http://github.com').then(() => {
|
||||
win.loadURL('https://github.com').then(() => {
|
||||
const currentURL = win.webContents.getURL()
|
||||
console.log(currentURL)
|
||||
})
|
||||
|
@ -1543,14 +1543,6 @@ If you would like the page to stay hidden, you should ensure that `stayHidden` i
|
|||
Returns `boolean` - Whether this page is being captured. It returns true when the capturer count
|
||||
is large then 0.
|
||||
|
||||
#### `contents.getPrinters()` _Deprecated_
|
||||
|
||||
Get the system printer list.
|
||||
|
||||
Returns [`PrinterInfo[]`](latest/api/structures/printer-info.md)
|
||||
|
||||
**Deprecated:** Should use the new [`contents.getPrintersAsync`](latest/api/web-contents.md#contentsgetprintersasync) API.
|
||||
|
||||
#### `contents.getPrintersAsync()`
|
||||
|
||||
Get the system printer list.
|
||||
|
@ -1629,7 +1621,7 @@ win.webContents.print(options, (success, errorType) => {
|
|||
* `bottom` number (optional) - Bottom margin in inches. Defaults to 1cm (~0.4 inches).
|
||||
* `left` number (optional) - Left margin in inches. Defaults to 1cm (~0.4 inches).
|
||||
* `right` number (optional) - Right margin in inches. Defaults to 1cm (~0.4 inches).
|
||||
* `pageRanges` string (optional) - Paper ranges to print, e.g., '1-5, 8, 11-13'. Defaults to the empty string, which means print all pages.
|
||||
* `pageRanges` string (optional) - Page ranges to print, e.g., '1-5, 8, 11-13'. Defaults to the empty string, which means print all pages.
|
||||
* `headerTemplate` string (optional) - HTML template for the print header. Should be valid HTML markup with following classes used to inject printing values into them: `date` (formatted print date), `title` (document title), `url` (document location), `pageNumber` (current page number) and `totalPages` (total pages in the document). For example, `<span class=title></span>` would generate span containing the title.
|
||||
* `footerTemplate` string (optional) - HTML template for the print footer. Should use the same format as the `headerTemplate`.
|
||||
* `preferCSSPageSize` boolean (optional) - Whether or not to prefer page size as defined by css. Defaults to false, in which case the content will be scaled to fit the paper size.
|
||||
|
@ -1649,7 +1641,7 @@ const path = require('node:path')
|
|||
const os = require('node:os')
|
||||
|
||||
const win = new BrowserWindow()
|
||||
win.loadURL('http://github.com')
|
||||
win.loadURL('https://github.com')
|
||||
|
||||
win.webContents.on('did-finish-load', () => {
|
||||
// Use default printing options
|
||||
|
@ -1775,6 +1767,7 @@ app.whenReady().then(() => {
|
|||
In `undocked` mode it's possible to dock back. In `detach` mode it's not.
|
||||
* `activate` boolean (optional) - Whether to bring the opened devtools window
|
||||
to the foreground. The default is `true`.
|
||||
* `title` string (optional) - A title for the DevTools window (only in `undocked` or `detach` mode).
|
||||
|
||||
Opens the devtools.
|
||||
|
||||
|
@ -1795,6 +1788,18 @@ Returns `boolean` - Whether the devtools is opened.
|
|||
|
||||
Returns `boolean` - Whether the devtools view is focused .
|
||||
|
||||
#### `contents.getDevToolsTitle()`
|
||||
|
||||
Returns `string` - the current title of the DevTools window. This will only be visible
|
||||
if DevTools is opened in `undocked` or `detach` mode.
|
||||
|
||||
#### `contents.setDevToolsTitle(title)`
|
||||
|
||||
* `title` string
|
||||
|
||||
Changes the title of the DevTools window to `title`. This will only be visible if DevTools is
|
||||
opened in `undocked` or `detach` mode.
|
||||
|
||||
#### `contents.toggleDevTools()`
|
||||
|
||||
Toggles the developer tools.
|
||||
|
|
|
@ -119,7 +119,7 @@ The `src` attribute can also accept data URLs, such as
|
|||
### `nodeintegration`
|
||||
|
||||
```html
|
||||
<webview src="http://www.google.com/" nodeintegration></webview>
|
||||
<webview src="https://www.google.com/" nodeintegration></webview>
|
||||
```
|
||||
|
||||
A `boolean`. When this attribute is present the guest page in `webview` will have node
|
||||
|
@ -130,7 +130,7 @@ page.
|
|||
### `nodeintegrationinsubframes`
|
||||
|
||||
```html
|
||||
<webview src="http://www.google.com/" nodeintegrationinsubframes></webview>
|
||||
<webview src="https://www.google.com/" nodeintegrationinsubframes></webview>
|
||||
```
|
||||
|
||||
A `boolean` for the experimental option for enabling NodeJS support in sub-frames such as iframes
|
||||
|
@ -168,7 +168,7 @@ after this script has finished executing.
|
|||
### `httpreferrer`
|
||||
|
||||
```html
|
||||
<webview src="https://www.github.com/" httpreferrer="http://cheng.guru"></webview>
|
||||
<webview src="https://www.github.com/" httpreferrer="https://example.com/"></webview>
|
||||
```
|
||||
|
||||
A `string` that sets the referrer URL for the guest page.
|
||||
|
@ -610,7 +610,7 @@ Prints `webview`'s web page. Same as `webContents.print([options])`.
|
|||
* `bottom` number (optional) - Bottom margin in inches. Defaults to 1cm (~0.4 inches).
|
||||
* `left` number (optional) - Left margin in inches. Defaults to 1cm (~0.4 inches).
|
||||
* `right` number (optional) - Right margin in inches. Defaults to 1cm (~0.4 inches).
|
||||
* `pageRanges` string (optional) - Paper ranges to print, e.g., '1-5, 8, 11-13'. Defaults to the empty string, which means print all pages.
|
||||
* `pageRanges` string (optional) - Page ranges to print, e.g., '1-5, 8, 11-13'. Defaults to the empty string, which means print all pages.
|
||||
* `headerTemplate` string (optional) - HTML template for the print header. Should be valid HTML markup with following classes used to inject printing values into them: `date` (formatted print date), `title` (document title), `url` (document location), `pageNumber` (current page number) and `totalPages` (total pages in the document). For example, `<span class=title></span>` would generate span containing the title.
|
||||
* `footerTemplate` string (optional) - HTML template for the print footer. Should use the same format as the `headerTemplate`.
|
||||
* `preferCSSPageSize` boolean (optional) - Whether or not to prefer page size as defined by css. Defaults to false, in which case the content will be scaled to fit the paper size.
|
||||
|
|
|
@ -28,6 +28,81 @@ macOS 10.13 (High Sierra) and macOS 10.14 (Mojave) are no longer supported by [C
|
|||
Older versions of Electron will continue to run on these operating systems, but macOS 10.15 (Catalina)
|
||||
or later will be required to run Electron v27.0.0 and higher.
|
||||
|
||||
### Deprecated: `ipcRenderer.sendTo()`
|
||||
|
||||
The `ipcRenderer.sendTo()` API has been deprecated. It should be replaced by setting up a [`MessageChannel`](latest/tutorial/message-ports.md#setting-up-a-messagechannel-between-two-renderers) between the renderers.
|
||||
|
||||
The `senderId` and `senderIsMainFrame` properties of `IpcRendererEvent` have been deprecated as well.
|
||||
|
||||
### Removed: color scheme events in `systemPreferences`
|
||||
|
||||
The following `systemPreferences` events have been removed:
|
||||
|
||||
* `inverted-color-scheme-changed`
|
||||
* `high-contrast-color-scheme-changed`
|
||||
|
||||
Use the new `updated` event on the `nativeTheme` module instead.
|
||||
|
||||
```js
|
||||
// Removed
|
||||
systemPreferences.on('inverted-color-scheme-changed', () => { /* ... */ })
|
||||
systemPreferences.on('high-contrast-color-scheme-changed', () => { /* ... */ })
|
||||
|
||||
// Replace with
|
||||
nativeTheme.on('updated', () => { /* ... */ })
|
||||
```
|
||||
|
||||
### Removed: `webContents.getPrinters`
|
||||
|
||||
The `webContents.getPrinters` method has been removed. Use
|
||||
`webContents.getPrintersAsync` instead.
|
||||
|
||||
```js
|
||||
const w = new BrowserWindow({ show: false })
|
||||
|
||||
// Removed
|
||||
console.log(w.webContents.getPrinters())
|
||||
// Replace with
|
||||
w.webContents.getPrintersAsync().then((printers) => {
|
||||
console.log(printers)
|
||||
})
|
||||
```
|
||||
|
||||
### Removed: `systemPreferences.{get,set}AppLevelAppearance` and `systemPreferences.appLevelAppearance`
|
||||
|
||||
The `systemPreferences.getAppLevelAppearance` and `systemPreferences.setAppLevelAppearance`
|
||||
methods have been removed, as well as the `systemPreferences.appLevelAppearance` property.
|
||||
Use the `nativeTheme` module instead.
|
||||
|
||||
```js
|
||||
// Removed
|
||||
systemPreferences.getAppLevelAppearance()
|
||||
// Replace with
|
||||
nativeTheme.shouldUseDarkColors
|
||||
|
||||
// Removed
|
||||
systemPreferences.appLevelAppearance
|
||||
// Replace with
|
||||
nativeTheme.shouldUseDarkColors
|
||||
|
||||
// Removed
|
||||
systemPreferences.setAppLevelAppearance('dark')
|
||||
// Replace with
|
||||
nativeTheme.themeSource = 'dark'
|
||||
```
|
||||
|
||||
### Removed: `alternate-selected-control-text` value for `systemPreferences.getColor`
|
||||
|
||||
The `alternate-selected-control-text` value for `systemPreferences.getColor`
|
||||
has been removed. Use `selected-content-background` instead.
|
||||
|
||||
```js
|
||||
// Removed
|
||||
systemPreferences.getColor('alternate-selected-control-text')
|
||||
// Replace with
|
||||
systemPreferences.getColor('selected-content-background')
|
||||
```
|
||||
|
||||
## Planned Breaking API Changes (26.0)
|
||||
|
||||
### Deprecated: `webContents.getPrinters`
|
||||
|
|
|
@ -30,7 +30,7 @@ store from `.pdb` files.
|
|||
SDK, open Visual Studio Installer, select
|
||||
`Modify` → `Individual Components`, scroll down and select the appropriate
|
||||
Windows SDK to install. Another option would be to look at the
|
||||
[Windows SDK and emulator archive](https://developer.microsoft.com/en-us/windows/downloads/sdk-archive)
|
||||
[Windows SDK and emulator archive](https://developer.microsoft.com/en-us/windows/downloads/sdk-archive/)
|
||||
and download the standalone version of the SDK respectively.
|
||||
* The SDK Debugging Tools must also be installed. If the Windows 10 SDK was installed
|
||||
via the Visual Studio installer, then they can be installed by going to:
|
||||
|
@ -39,7 +39,7 @@ store from `.pdb` files.
|
|||
Or, you can download the standalone SDK installer and use it to install the Debugging Tools.
|
||||
|
||||
If you don't currently have a Windows installation,
|
||||
[dev.microsoftedge.com](https://developer.microsoft.com/en-us/microsoft-edge/tools/vms/)
|
||||
[developer.microsoft.com](https://developer.microsoft.com/en-us/windows/downloads/virtual-machines/)
|
||||
has timebombed versions of Windows that you can use to build Electron.
|
||||
|
||||
Building Electron is done entirely with command-line scripts and cannot be done
|
||||
|
|
|
@ -136,9 +136,9 @@ void Initialize(v8::Local<v8::Object> exports,
|
|||
|
||||
In the [`typings/internal-ambient.d.ts`](https://github.com/electron/electron/blob/main/typings/internal-ambient.d.ts) file, we need to append a new property onto the `Process` interface like so:
|
||||
|
||||
```ts title='typings/internal-ambient.d.ts'
|
||||
```ts title='typings/internal-ambient.d.ts' @ts-nocheck
|
||||
interface Process {
|
||||
_linkedBinding(name: 'electron_browser_{api_name}', Electron.ApiName);
|
||||
_linkedBinding(name: 'electron_browser_{api_name}'): Electron.ApiName;
|
||||
}
|
||||
```
|
||||
|
||||
|
@ -171,7 +171,7 @@ An example of the contents of this file can be found [here](https://github.com/e
|
|||
|
||||
Add your module to the module list found at `"lib/browser/api/module-list.ts"` like so:
|
||||
|
||||
```typescript title='lib/browser/api/module-list.ts'
|
||||
```typescript title='lib/browser/api/module-list.ts' @ts-nocheck
|
||||
export const browserModuleList: ElectronInternal.ModuleEntry[] = [
|
||||
{ name: 'apiName', loader: () => require('./api-name') },
|
||||
];
|
||||
|
|
|
@ -95,7 +95,7 @@ is doing to the operating system, it can be a valuable resource.
|
|||
For an introduction to ProcMon's basic and advanced debugging features, go check
|
||||
out [this video tutorial][procmon-instructions] provided by Microsoft.
|
||||
|
||||
[sys-internals]: https://technet.microsoft.com/en-us/sysinternals/processmonitor.aspx
|
||||
[sys-internals]: https://learn.microsoft.com/en-us/sysinternals/downloads/procmon
|
||||
[procmon-instructions]: https://learn.microsoft.com/en-us/shows/defrag-tools/4-process-monitor
|
||||
|
||||
## Using WinDbg
|
||||
|
|
|
@ -31,7 +31,7 @@ contribute:
|
|||
|
||||
## Asking for General Help
|
||||
|
||||
[The Electron website](https://electronjs.org/community) has a
|
||||
[The Electron website](https://www.electronjs.org/community) has a
|
||||
list of resources for getting programming help, reporting security issues,
|
||||
contributing, and more. Please use the issue tracker for bugs only!
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
const { app, BrowserWindow, ipcMain, nativeTheme } = require('electron')
|
||||
const path = require('path')
|
||||
const path = require('node:path')
|
||||
|
||||
function createWindow () {
|
||||
const win = new BrowserWindow({
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
const { app, BrowserWindow, ipcMain } = require('electron')
|
||||
const path = require('path')
|
||||
const fs = require('fs')
|
||||
const https = require('https')
|
||||
const path = require('node:path')
|
||||
const fs = require('node:fs')
|
||||
const https = require('node:https')
|
||||
|
||||
function createWindow () {
|
||||
const win = new BrowserWindow({
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
const { app, BrowserWindow } = require('electron')
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
const fs = require('node:fs')
|
||||
const path = require('node:path')
|
||||
|
||||
app.disableHardwareAcceleration()
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
const { app, BrowserWindow } = require('electron')
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
const fs = require('node:fs')
|
||||
const path = require('node:path')
|
||||
|
||||
function createWindow () {
|
||||
const win = new BrowserWindow({
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
const { app, BrowserWindow } = require('electron')
|
||||
const os = require('os')
|
||||
const os = require('node:os')
|
||||
|
||||
function createWindow () {
|
||||
const win = new BrowserWindow({
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
const { app, BrowserWindow, ipcMain } = require('electron')
|
||||
const path = require('path')
|
||||
const path = require('node:path')
|
||||
|
||||
let bluetoothPinCallback
|
||||
let selectBluetoothCallback
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
const { app, BrowserWindow, ipcMain } = require('electron')
|
||||
const path = require('path')
|
||||
const path = require('node:path')
|
||||
|
||||
function createWindow () {
|
||||
const mainWindow = new BrowserWindow({
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
const { app, BrowserWindow, ipcMain, dialog } = require('electron')
|
||||
const path = require('path')
|
||||
const path = require('node:path')
|
||||
|
||||
async function handleFileOpen () {
|
||||
const { canceled, filePaths } = await dialog.showOpenDialog()
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
const { app, BrowserWindow, Menu, ipcMain } = require('electron')
|
||||
const path = require('path')
|
||||
const path = require('node:path')
|
||||
|
||||
function createWindow () {
|
||||
const mainWindow = new BrowserWindow({
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// Modules to control application life and create native browser window
|
||||
const { app, BrowserWindow } = require('electron')
|
||||
const path = require('path')
|
||||
const path = require('node:path')
|
||||
|
||||
function createWindow () {
|
||||
// Create the browser window.
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
const { BrowserWindow, app, screen, ipcMain } = require('electron')
|
||||
const { BrowserWindow, app, screen, ipcMain, desktopCapturer } = require('electron')
|
||||
|
||||
let mainWindow = null
|
||||
|
||||
|
@ -6,12 +6,17 @@ ipcMain.handle('get-screen-size', () => {
|
|||
return screen.getPrimaryDisplay().workAreaSize
|
||||
})
|
||||
|
||||
ipcMain.handle('get-sources', (event, options) => {
|
||||
return desktopCapturer.getSources(options)
|
||||
})
|
||||
|
||||
function createWindow () {
|
||||
const windowOptions = {
|
||||
width: 600,
|
||||
height: 300,
|
||||
title: 'Take a Screenshot',
|
||||
webPreferences: {
|
||||
contextIsolation: false,
|
||||
nodeIntegration: true
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
const { desktopCapturer, shell, ipcRenderer } = require('electron')
|
||||
const { shell, ipcRenderer } = require('electron')
|
||||
|
||||
const fs = require('fs')
|
||||
const os = require('os')
|
||||
const path = require('path')
|
||||
const fs = require('node:fs').promises
|
||||
const os = require('node:os')
|
||||
const path = require('node:path')
|
||||
|
||||
const screenshot = document.getElementById('screen-shot')
|
||||
const screenshotMsg = document.getElementById('screenshot-path')
|
||||
|
@ -12,24 +12,19 @@ screenshot.addEventListener('click', async (event) => {
|
|||
const thumbSize = await determineScreenShotSize()
|
||||
const options = { types: ['screen'], thumbnailSize: thumbSize }
|
||||
|
||||
desktopCapturer.getSources(options, (error, sources) => {
|
||||
if (error) return console.log(error)
|
||||
const sources = await ipcRenderer.invoke('get-sources', options)
|
||||
for (const source of sources) {
|
||||
const sourceName = source.name.toLowerCase()
|
||||
if (sourceName === 'entire screen' || sourceName === 'screen 1') {
|
||||
const screenshotPath = path.join(os.tmpdir(), 'screenshot.png')
|
||||
|
||||
sources.forEach((source) => {
|
||||
const sourceName = source.name.toLowerCase()
|
||||
if (sourceName === 'entire screen' || sourceName === 'screen 1') {
|
||||
const screenshotPath = path.join(os.tmpdir(), 'screenshot.png')
|
||||
await fs.writeFile(screenshotPath, source.thumbnail.toPNG())
|
||||
shell.openExternal(`file://${screenshotPath}`)
|
||||
|
||||
fs.writeFile(screenshotPath, source.thumbnail.toPNG(), (error) => {
|
||||
if (error) return console.log(error)
|
||||
shell.openExternal(`file://${screenshotPath}`)
|
||||
|
||||
const message = `Saved screenshot to: ${screenshotPath}`
|
||||
screenshotMsg.textContent = message
|
||||
})
|
||||
}
|
||||
})
|
||||
})
|
||||
const message = `Saved screenshot to: ${screenshotPath}`
|
||||
screenshotMsg.textContent = message
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
async function determineScreenShotSize () {
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
|
||||
<p>
|
||||
Open the
|
||||
<a href="https://electronjs.org/docs/api/menu"
|
||||
<a href="https://www.electronjs.org/docs/latest/api/menu"
|
||||
>full API documentation<span
|
||||
>(opens in new window)</span
|
||||
></a
|
||||
|
@ -62,7 +62,7 @@
|
|||
<ul>
|
||||
<li>
|
||||
<a
|
||||
href="https://developer.apple.com/macos/human-interface-guidelines/menus/menu-anatomy/"
|
||||
href="https://developer.apple.com/design/human-interface-guidelines/the-menu-bar"
|
||||
>macOS<span
|
||||
>(opens in new window)</span
|
||||
></a
|
||||
|
@ -70,7 +70,7 @@
|
|||
</li>
|
||||
<li>
|
||||
<a
|
||||
href="https://learn.microsoft.com/en-us/previous-versions/windows/desktop/bb226797"
|
||||
href="https://learn.microsoft.com/en-us/windows/apps/design/controls/menus-and-context-menus"
|
||||
>Windows<span
|
||||
>(opens in new window)</span
|
||||
></a
|
||||
|
@ -78,7 +78,7 @@
|
|||
</li>
|
||||
<li>
|
||||
<a
|
||||
href="https://developer.gnome.org/hig/stable/menu-bars.html.en"
|
||||
href="https://developer.gnome.org/hig/patterns/controls/menus.html"
|
||||
>Linux<span
|
||||
>(opens in new window)</span
|
||||
></a
|
||||
|
@ -111,7 +111,7 @@
|
|||
<p>
|
||||
See the full
|
||||
<a
|
||||
href="https://electronjs.org/docs/api/web-contents/#event-context-menu"
|
||||
href="https://www.electronjs.org/docs/latest/api/web-contents/#event-context-menu"
|
||||
>context-menu event documentation</a
|
||||
>
|
||||
for all the available properties.
|
||||
|
|
|
@ -294,6 +294,7 @@ function createWindow () {
|
|||
width: 800,
|
||||
height: 600,
|
||||
webPreferences: {
|
||||
contextIsolation: false,
|
||||
nodeIntegration: true
|
||||
}
|
||||
})
|
||||
|
@ -311,6 +312,12 @@ function createWindow () {
|
|||
// when you should delete the corresponding element.
|
||||
mainWindow = null
|
||||
})
|
||||
|
||||
// Open external links in the default browser
|
||||
mainWindow.webContents.on('will-navigate', (event, url) => {
|
||||
event.preventDefault()
|
||||
shell.openExternal(url)
|
||||
})
|
||||
}
|
||||
|
||||
// This method will be called when Electron has finished
|
||||
|
|
|
@ -21,10 +21,10 @@
|
|||
|
||||
<p>
|
||||
Open the full documentation for the
|
||||
<a href="https://electronjs.org/docs/api/menu">Menu</a>,
|
||||
<a href="https://electronjs.org/docs/api/accelerator">Accelerator</a>,
|
||||
<a href="https://www.electronjs.org/docs/latest/api/menu">Menu</a>,
|
||||
<a href="https://www.electronjs.org/docs/latest/api/accelerator">Accelerator</a>,
|
||||
and
|
||||
<a href="https://electronjs.org/docs/api/global-shortcut">globalShortcut</a>
|
||||
<a href="https://www.electronjs.org/docs/latest/api/global-shortcut">globalShortcut</a>
|
||||
APIs in your browser.
|
||||
</p>
|
||||
|
||||
|
@ -56,12 +56,12 @@
|
|||
|
||||
<ul>
|
||||
<li><a
|
||||
href="https://developer.apple.com/library/mac/documentation/UserExperience/Conceptual/OSXHIGuidelines/Keyboard.html">macOS</a>
|
||||
href="https://developer.apple.com/design/human-interface-guidelines/keyboards">macOS</a>
|
||||
</li>
|
||||
<li><a
|
||||
href="http://windows.microsoft.com/en-us/windows-10/keyboard-shortcuts">Windows</a></li>
|
||||
href="https://support.microsoft.com/en-us/windows/keyboard-shortcuts-in-windows-dcc61a57-8ff0-cffe-9796-cb9706c75eec">Windows</a></li>
|
||||
<li><a
|
||||
href="https://developer.gnome.org/hig/stable/keyboard-input.html.en">Linux</a></li>
|
||||
href="https://developer.gnome.org/hig/guidelines/keyboard.html">Linux</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// Modules to control application life and create native browser window
|
||||
const { app, BrowserWindow, globalShortcut, dialog } = require('electron')
|
||||
const { app, BrowserWindow, globalShortcut, dialog, shell } = require('electron')
|
||||
|
||||
// Keep a global reference of the window object, if you don't, the window will
|
||||
// be closed automatically when the JavaScript object is garbage collected.
|
||||
|
@ -11,6 +11,7 @@ function createWindow () {
|
|||
width: 800,
|
||||
height: 600,
|
||||
webPreferences: {
|
||||
contextIsolation: false,
|
||||
nodeIntegration: true
|
||||
}
|
||||
})
|
||||
|
@ -37,6 +38,12 @@ function createWindow () {
|
|||
// when you should delete the corresponding element.
|
||||
mainWindow = null
|
||||
})
|
||||
|
||||
// Open external links in the default browser
|
||||
mainWindow.webContents.on('will-navigate', (event, url) => {
|
||||
event.preventDefault()
|
||||
shell.openExternal(url)
|
||||
})
|
||||
}
|
||||
|
||||
// This method will be called when Electron has finished
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
|
||||
<p>
|
||||
Open the
|
||||
<a href="https://electronjs.org/docs/api/dialog/">
|
||||
<a href="https://www.electronjs.org/docs/latest/api/dialog/">
|
||||
full API documentation (opens in new window)
|
||||
</a>
|
||||
in your browser.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// Modules to control application life and create native browser window
|
||||
const { app, BrowserWindow, ipcMain, dialog } = require('electron')
|
||||
const { app, BrowserWindow, ipcMain, dialog, shell } = require('electron')
|
||||
|
||||
// Keep a global reference of the window object, if you don't, the window will
|
||||
// be closed automatically when the JavaScript object is garbage collected.
|
||||
|
@ -11,6 +11,7 @@ function createWindow () {
|
|||
width: 800,
|
||||
height: 600,
|
||||
webPreferences: {
|
||||
contextIsolation: false,
|
||||
nodeIntegration: true
|
||||
}
|
||||
})
|
||||
|
@ -28,6 +29,12 @@ function createWindow () {
|
|||
// when you should delete the corresponding element.
|
||||
mainWindow = null
|
||||
})
|
||||
|
||||
// Open external links in the default browser
|
||||
mainWindow.webContents.on('will-navigate', (event, url) => {
|
||||
event.preventDefault()
|
||||
shell.openExternal(url)
|
||||
})
|
||||
}
|
||||
|
||||
// This method will be called when Electron has finished
|
||||
|
|
|
@ -1,18 +1,7 @@
|
|||
const { ipcRenderer, shell } = require('electron')
|
||||
const { ipcRenderer } = require('electron')
|
||||
|
||||
const links = document.querySelectorAll('a[href]')
|
||||
const errorBtn = document.getElementById('error-dialog')
|
||||
|
||||
errorBtn.addEventListener('click', event => {
|
||||
ipcRenderer.send('open-error-dialog')
|
||||
})
|
||||
|
||||
Array.prototype.forEach.call(links, (link) => {
|
||||
const url = link.getAttribute('href')
|
||||
if (url.indexOf('http') === 0) {
|
||||
link.addEventListener('click', (e) => {
|
||||
e.preventDefault()
|
||||
shell.openExternal(url)
|
||||
})
|
||||
}
|
||||
})
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
|
||||
<p>
|
||||
Open the
|
||||
<a href="https://electronjs.org/docs/api/dialog/">
|
||||
<a href="https://www.electronjs.org/docs/latest/api/dialog/">
|
||||
full API documentation (opens in new window)
|
||||
</a>
|
||||
in your browser.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// Modules to control application life and create native browser window
|
||||
const { app, BrowserWindow, ipcMain, dialog } = require('electron')
|
||||
const { app, BrowserWindow, ipcMain, dialog, shell } = require('electron')
|
||||
|
||||
// Keep a global reference of the window object, if you don't, the window will
|
||||
// be closed automatically when the JavaScript object is garbage collected.
|
||||
|
@ -11,6 +11,7 @@ function createWindow () {
|
|||
width: 800,
|
||||
height: 600,
|
||||
webPreferences: {
|
||||
contextIsolation: false,
|
||||
nodeIntegration: true
|
||||
}
|
||||
})
|
||||
|
@ -28,6 +29,12 @@ function createWindow () {
|
|||
// when you should delete the corresponding element.
|
||||
mainWindow = null
|
||||
})
|
||||
|
||||
// Open external links in the default browser
|
||||
mainWindow.webContents.on('will-navigate', (event, url) => {
|
||||
event.preventDefault()
|
||||
shell.openExternal(url)
|
||||
})
|
||||
}
|
||||
|
||||
// This method will be called when Electron has finished
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
const { ipcRenderer, shell } = require('electron')
|
||||
const { ipcRenderer } = require('electron')
|
||||
|
||||
const informationBtn = document.getElementById('information-dialog')
|
||||
const links = document.querySelectorAll('a[href]')
|
||||
|
||||
informationBtn.addEventListener('click', event => {
|
||||
ipcRenderer.send('open-information-dialog')
|
||||
|
@ -13,13 +12,3 @@ ipcRenderer.on('information-dialog-selection', (event, index) => {
|
|||
else message += 'no.'
|
||||
document.getElementById('info-selection').innerHTML = message
|
||||
})
|
||||
|
||||
Array.prototype.forEach.call(links, (link) => {
|
||||
const url = link.getAttribute('href')
|
||||
if (url.indexOf('http') === 0) {
|
||||
link.addEventListener('click', (e) => {
|
||||
e.preventDefault()
|
||||
shell.openExternal(url)
|
||||
})
|
||||
}
|
||||
})
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
|
||||
<p>
|
||||
Open the
|
||||
<a href="https://electronjs.org/docs/api/dialog/">
|
||||
<a href="https://www.electronjs.org/docs/latest/api/dialog/">
|
||||
full API documentation (opens in new window)
|
||||
</a>
|
||||
in your browser.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// Modules to control application life and create native browser window
|
||||
const { app, BrowserWindow, ipcMain, dialog } = require('electron')
|
||||
const { app, BrowserWindow, ipcMain, dialog, shell } = require('electron')
|
||||
|
||||
// Keep a global reference of the window object, if you don't, the window will
|
||||
// be closed automatically when the JavaScript object is garbage collected.
|
||||
|
@ -11,6 +11,7 @@ function createWindow () {
|
|||
width: 800,
|
||||
height: 600,
|
||||
webPreferences: {
|
||||
contextIsolation: false,
|
||||
nodeIntegration: true
|
||||
}
|
||||
})
|
||||
|
@ -28,6 +29,12 @@ function createWindow () {
|
|||
// when you should delete the corresponding element.
|
||||
mainWindow = null
|
||||
})
|
||||
|
||||
// Open external links in the default browser
|
||||
mainWindow.webContents.on('will-navigate', (event, url) => {
|
||||
event.preventDefault()
|
||||
shell.openExternal(url)
|
||||
})
|
||||
}
|
||||
|
||||
// This method will be called when Electron has finished
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
const { ipcRenderer, shell } = require('electron')
|
||||
const { ipcRenderer } = require('electron')
|
||||
|
||||
const selectDirBtn = document.getElementById('select-directory')
|
||||
const links = document.querySelectorAll('a[href]')
|
||||
|
||||
selectDirBtn.addEventListener('click', event => {
|
||||
ipcRenderer.send('open-file-dialog')
|
||||
|
@ -10,13 +9,3 @@ selectDirBtn.addEventListener('click', event => {
|
|||
ipcRenderer.on('selected-directory', (event, path) => {
|
||||
document.getElementById('selected-file').innerHTML = `You selected: ${path}`
|
||||
})
|
||||
|
||||
Array.prototype.forEach.call(links, (link) => {
|
||||
const url = link.getAttribute('href')
|
||||
if (url.indexOf('http') === 0) {
|
||||
link.addEventListener('click', (e) => {
|
||||
e.preventDefault()
|
||||
shell.openExternal(url)
|
||||
})
|
||||
}
|
||||
})
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
|
||||
<p>
|
||||
Open the
|
||||
<a href="https://electronjs.org/docs/api/dialog/">
|
||||
<a href="https://www.electronjs.org/docs/latest/api/dialog/">
|
||||
full API documentation (opens in new window)
|
||||
</a>
|
||||
in your browser.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// Modules to control application life and create native browser window
|
||||
const { app, BrowserWindow, ipcMain, dialog } = require('electron')
|
||||
const { app, BrowserWindow, ipcMain, dialog, shell } = require('electron')
|
||||
|
||||
// Keep a global reference of the window object, if you don't, the window will
|
||||
// be closed automatically when the JavaScript object is garbage collected.
|
||||
|
@ -11,6 +11,7 @@ function createWindow () {
|
|||
width: 800,
|
||||
height: 600,
|
||||
webPreferences: {
|
||||
contextIsolation: false,
|
||||
nodeIntegration: true
|
||||
}
|
||||
})
|
||||
|
@ -28,6 +29,12 @@ function createWindow () {
|
|||
// when you should delete the corresponding element.
|
||||
mainWindow = null
|
||||
})
|
||||
|
||||
// Open external links in the default browser
|
||||
mainWindow.webContents.on('will-navigate', (event, url) => {
|
||||
event.preventDefault()
|
||||
shell.openExternal(url)
|
||||
})
|
||||
}
|
||||
|
||||
// This method will be called when Electron has finished
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
const { ipcRenderer, shell } = require('electron')
|
||||
const { ipcRenderer } = require('electron')
|
||||
|
||||
const saveBtn = document.getElementById('save-dialog')
|
||||
const links = document.querySelectorAll('a[href]')
|
||||
|
||||
saveBtn.addEventListener('click', event => {
|
||||
ipcRenderer.send('save-dialog')
|
||||
|
@ -11,13 +10,3 @@ ipcRenderer.on('saved-file', (event, path) => {
|
|||
if (!path) path = 'No path'
|
||||
document.getElementById('file-saved').innerHTML = `Path selected: ${path}`
|
||||
})
|
||||
|
||||
Array.prototype.forEach.call(links, (link) => {
|
||||
const url = link.getAttribute('href')
|
||||
if (url.indexOf('http') === 0) {
|
||||
link.addEventListener('click', (e) => {
|
||||
e.preventDefault()
|
||||
shell.openExternal(url)
|
||||
})
|
||||
}
|
||||
})
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
|
||||
<p>
|
||||
Open the
|
||||
<a href="https://electronjs.org/docs/tutorial/native-file-drag-drop">
|
||||
<a href="https://www.electronjs.org/docs/latest/tutorial/native-file-drag-drop">
|
||||
full API documentation (opens in new window)
|
||||
</a>
|
||||
in your browser.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// Modules to control application life and create native browser window
|
||||
const { app, BrowserWindow, ipcMain, nativeImage } = require('electron')
|
||||
const { app, BrowserWindow, ipcMain, nativeImage, shell } = require('electron')
|
||||
// Keep a global reference of the window object, if you don't, the window will
|
||||
// be closed automatically when the JavaScript object is garbage collected.
|
||||
let mainWindow
|
||||
|
@ -10,6 +10,7 @@ function createWindow () {
|
|||
width: 800,
|
||||
height: 600,
|
||||
webPreferences: {
|
||||
contextIsolation: false,
|
||||
nodeIntegration: true
|
||||
}
|
||||
})
|
||||
|
@ -27,6 +28,12 @@ function createWindow () {
|
|||
// when you should delete the corresponding element.
|
||||
mainWindow = null
|
||||
})
|
||||
|
||||
// Open external links in the default browser
|
||||
mainWindow.webContents.on('will-navigate', (event, url) => {
|
||||
event.preventDefault()
|
||||
shell.openExternal(url)
|
||||
})
|
||||
}
|
||||
|
||||
// This method will be called when Electron has finished
|
||||
|
|
|
@ -1,17 +1,4 @@
|
|||
const { ipcRenderer } = require('electron')
|
||||
const shell = require('electron').shell
|
||||
|
||||
const links = document.querySelectorAll('a[href]')
|
||||
|
||||
Array.prototype.forEach.call(links, (link) => {
|
||||
const url = link.getAttribute('href')
|
||||
if (url.indexOf('http') === 0) {
|
||||
link.addEventListener('click', (e) => {
|
||||
e.preventDefault()
|
||||
shell.openExternal(url)
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
const dragFileLink = document.getElementById('drag-file-link')
|
||||
|
||||
|
|
|
@ -1,67 +0,0 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<title>Open external links</title>
|
||||
</head>
|
||||
<body>
|
||||
<div class="demo">
|
||||
<div class="demo-wrapper">
|
||||
<div class="demo-box">
|
||||
<div class="demo-controls">
|
||||
<button class="demo-button" id="open-ex-links">View Demo</button>
|
||||
</div>
|
||||
<p>
|
||||
If you do not want your app to open website links
|
||||
<em>within</em> the app, you can use the <code>shell</code> module
|
||||
to open them externally. When clicked, the links will open outside
|
||||
of your app and in the user's default web browser.
|
||||
</p>
|
||||
<p>
|
||||
When the demo button is clicked, the electron website will open in
|
||||
your browser.
|
||||
</p>
|
||||
<p></p>
|
||||
<h5>Renderer Process</h5>
|
||||
<pre><code>
|
||||
const { shell } = require('electron')
|
||||
const exLinksBtn = document.getElementById('open-ex-links')
|
||||
exLinksBtn.addEventListener('click', (event) => {
|
||||
shell.openExternal('https://electronjs.org')
|
||||
})
|
||||
</code></pre>
|
||||
|
||||
<div class="demo-protip">
|
||||
<h2>ProTip</h2>
|
||||
<strong>Open all outbound links externally.</strong>
|
||||
<p>
|
||||
You may want to open all <code>http</code> and
|
||||
<code>https</code> links outside of your app. To do this, query
|
||||
the document and loop through each link and add a listener. This
|
||||
app uses the code below which is located in
|
||||
<code>assets/ex-links.js</code>.
|
||||
</p>
|
||||
<h5>Renderer Process</h5>
|
||||
<pre><code>
|
||||
const { shell } = require('electron')
|
||||
const links = document.querySelectorAll('a[href]')
|
||||
Array.prototype.forEach.call(links, (link) => {
|
||||
const url = link.getAttribute('href')
|
||||
if (url.indexOf('http') === 0) {
|
||||
link.addEventListener('click', (e) => {
|
||||
e.preventDefault()
|
||||
shell.openExternal(url)
|
||||
})
|
||||
}})
|
||||
</code></pre>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
// You can also require other files to run in this process
|
||||
require("./renderer.js");
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -1,25 +0,0 @@
|
|||
const { app, BrowserWindow } = require('electron')
|
||||
|
||||
let mainWindow = null
|
||||
|
||||
function createWindow () {
|
||||
const windowOptions = {
|
||||
width: 600,
|
||||
height: 400,
|
||||
title: 'Open External Links',
|
||||
webPreferences: {
|
||||
nodeIntegration: true
|
||||
}
|
||||
}
|
||||
|
||||
mainWindow = new BrowserWindow(windowOptions)
|
||||
mainWindow.loadFile('index.html')
|
||||
|
||||
mainWindow.on('closed', () => {
|
||||
mainWindow = null
|
||||
})
|
||||
}
|
||||
|
||||
app.whenReady().then(() => {
|
||||
createWindow()
|
||||
})
|
|
@ -1,7 +0,0 @@
|
|||
const { shell } = require('electron')
|
||||
|
||||
const exLinksBtn = document.getElementById('open-ex-links')
|
||||
|
||||
exLinksBtn.addEventListener('click', (event) => {
|
||||
shell.openExternal('https://electronjs.org')
|
||||
})
|
|
@ -17,7 +17,7 @@
|
|||
<p>This module works in both the main and renderer process.</p>
|
||||
<p>
|
||||
Open the
|
||||
<a href="https://electronjs.org/docs/api/shell">
|
||||
<a href="https://www.electronjs.org/docs/latest/api/shell">
|
||||
full API documentation (opens in new window)
|
||||
</a>
|
||||
in your browser.
|
||||
|
@ -80,7 +80,7 @@ const shell = require('electron').shell
|
|||
|
||||
const links = document.querySelectorAll('a[href]')
|
||||
|
||||
Array.prototype.forEach.call(links, (link) => {
|
||||
for (const link of links) {
|
||||
const url = link.getAttribute('href')
|
||||
if (url.indexOf('http') === 0) {
|
||||
link.addEventListener('click', (e) => {
|
||||
|
@ -88,7 +88,7 @@ Array.prototype.forEach.call(links, (link) => {
|
|||
shell.openExternal(url)
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
</code>
|
||||
</pre>
|
||||
</div>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// Modules to control application life and create native browser window
|
||||
const { app, BrowserWindow } = require('electron')
|
||||
const { app, BrowserWindow, shell } = require('electron')
|
||||
|
||||
// Keep a global reference of the window object, if you don't, the window will
|
||||
// be closed automatically when the JavaScript object is garbage collected.
|
||||
|
@ -11,6 +11,7 @@ function createWindow () {
|
|||
width: 800,
|
||||
height: 600,
|
||||
webPreferences: {
|
||||
contextIsolation: false,
|
||||
nodeIntegration: true
|
||||
}
|
||||
})
|
||||
|
@ -28,6 +29,12 @@ function createWindow () {
|
|||
// when you should delete the corresponding element.
|
||||
mainWindow = null
|
||||
})
|
||||
|
||||
// Open external links in the default browser
|
||||
mainWindow.webContents.on('will-navigate', (event, url) => {
|
||||
event.preventDefault()
|
||||
shell.openExternal(url)
|
||||
})
|
||||
}
|
||||
|
||||
// This method will be called when Electron has finished
|
||||
|
|
|
@ -1,24 +0,0 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
</head>
|
||||
<body>
|
||||
<div>
|
||||
<div>
|
||||
<h1>Open Path in File Manager</h1>
|
||||
<i>Supports: Win, macOS, Linux <span>|</span> Process: Both</i>
|
||||
<div>
|
||||
<p>This demonstrates using the <code>shell</code> module to open the system file manager at a particular location.</p>
|
||||
<p>Clicking the demo button will open your file manager at the root.</p>
|
||||
<div>
|
||||
<button id="open-file-manager">View Demo</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
<script>
|
||||
require('./renderer.js')
|
||||
</script>
|
||||
</html>
|
|
@ -1,25 +0,0 @@
|
|||
const { app, BrowserWindow } = require('electron')
|
||||
|
||||
let mainWindow = null
|
||||
|
||||
function createWindow () {
|
||||
const windowOptions = {
|
||||
width: 600,
|
||||
height: 400,
|
||||
title: 'Open Path in File Manager',
|
||||
webPreferences: {
|
||||
nodeIntegration: true
|
||||
}
|
||||
}
|
||||
|
||||
mainWindow = new BrowserWindow(windowOptions)
|
||||
mainWindow.loadFile('index.html')
|
||||
|
||||
mainWindow.on('closed', () => {
|
||||
mainWindow = null
|
||||
})
|
||||
}
|
||||
|
||||
app.whenReady().then(() => {
|
||||
createWindow()
|
||||
})
|
|
@ -1,8 +0,0 @@
|
|||
const { shell } = require('electron')
|
||||
const os = require('os')
|
||||
|
||||
const fileManagerBtn = document.getElementById('open-file-manager')
|
||||
|
||||
fileManagerBtn.addEventListener('click', (event) => {
|
||||
shell.showItemInFolder(os.homedir())
|
||||
})
|
|
@ -1,5 +1,5 @@
|
|||
const { shell } = require('electron')
|
||||
const os = require('os')
|
||||
const os = require('node:os')
|
||||
|
||||
const exLinksBtn = document.getElementById('open-ex-links')
|
||||
const fileManagerBtn = document.getElementById('open-file-manager')
|
||||
|
|
|
@ -1,22 +0,0 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
</head>
|
||||
<body>
|
||||
<div>
|
||||
<h3>Basic notification</h3>
|
||||
<i>Supports: Win 7+, macOS, Linux (that supports libnotify)<span>|</span> Process: Renderer</i>
|
||||
<div>
|
||||
<div>
|
||||
<button id="basic-noti">View demo</button>
|
||||
</div>
|
||||
<p>This demo demonstrates a basic notification. Text only.</p>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
// You can also require other files to run in this process
|
||||
require('./renderer.js')
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -1,25 +0,0 @@
|
|||
const { BrowserWindow, app } = require('electron')
|
||||
|
||||
let mainWindow = null
|
||||
|
||||
function createWindow () {
|
||||
const windowOptions = {
|
||||
width: 600,
|
||||
height: 300,
|
||||
title: 'Basic Notification',
|
||||
webPreferences: {
|
||||
nodeIntegration: true
|
||||
}
|
||||
}
|
||||
|
||||
mainWindow = new BrowserWindow(windowOptions)
|
||||
mainWindow.loadFile('index.html')
|
||||
|
||||
mainWindow.on('closed', () => {
|
||||
mainWindow = null
|
||||
})
|
||||
}
|
||||
|
||||
app.whenReady().then(() => {
|
||||
createWindow()
|
||||
})
|
|
@ -1,14 +0,0 @@
|
|||
const notification = {
|
||||
title: 'Basic Notification',
|
||||
body: 'Short message part'
|
||||
}
|
||||
|
||||
const notificationButton = document.getElementById('basic-noti')
|
||||
|
||||
notificationButton.addEventListener('click', () => {
|
||||
const myNotification = new window.Notification(notification.title, notification)
|
||||
|
||||
myNotification.onclick = () => {
|
||||
console.log('Notification clicked')
|
||||
}
|
||||
})
|
|
@ -26,7 +26,7 @@
|
|||
|
||||
<p>
|
||||
Open the
|
||||
<a href="https://electronjs.org/docs/all/#notifications-windows-linux-macos">
|
||||
<a href="https://www.electronjs.org/docs/latest/tutorial/notifications">
|
||||
full API documentation<span>(opens in new window)</span>
|
||||
</a>
|
||||
in your browser.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// Modules to control application life and create native browser window
|
||||
const { app, BrowserWindow } = require('electron')
|
||||
const { app, BrowserWindow, shell } = require('electron')
|
||||
|
||||
// Keep a global reference of the window object, if you don't, the window will
|
||||
// be closed automatically when the JavaScript object is garbage collected.
|
||||
|
@ -11,6 +11,7 @@ function createWindow () {
|
|||
width: 800,
|
||||
height: 600,
|
||||
webPreferences: {
|
||||
contextIsolation: false,
|
||||
nodeIntegration: true
|
||||
}
|
||||
})
|
||||
|
@ -28,6 +29,12 @@ function createWindow () {
|
|||
// when you should delete the corresponding element.
|
||||
mainWindow = null
|
||||
})
|
||||
|
||||
// Open external links in the default browser
|
||||
mainWindow.webContents.on('will-navigate', (event, url) => {
|
||||
event.preventDefault()
|
||||
shell.openExternal(url)
|
||||
})
|
||||
}
|
||||
|
||||
// This method will be called when Electron has finished
|
||||
|
|
|
@ -1,22 +0,0 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
</head>
|
||||
<body>
|
||||
<div>
|
||||
<h3>Notification with image</h3>
|
||||
<i>Supports: Win 7+, macOS, Linux (that supports libnotify)<span>|</span> Process: Renderer</i>
|
||||
<div>
|
||||
<div>
|
||||
<button id="advanced-noti">View demo</button>
|
||||
</div>
|
||||
<p>This demo demonstrates an advanced notification. Both text and image.</p>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
// You can also require other files to run in this process
|
||||
require('./renderer.js')
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -1,25 +0,0 @@
|
|||
const { BrowserWindow, app } = require('electron')
|
||||
|
||||
let mainWindow = null
|
||||
|
||||
function createWindow () {
|
||||
const windowOptions = {
|
||||
width: 600,
|
||||
height: 300,
|
||||
title: 'Advanced Notification',
|
||||
webPreferences: {
|
||||
nodeIntegration: true
|
||||
}
|
||||
}
|
||||
|
||||
mainWindow = new BrowserWindow(windowOptions)
|
||||
mainWindow.loadFile('index.html')
|
||||
|
||||
mainWindow.on('closed', () => {
|
||||
mainWindow = null
|
||||
})
|
||||
}
|
||||
|
||||
app.whenReady().then(() => {
|
||||
createWindow()
|
||||
})
|
|
@ -1,14 +0,0 @@
|
|||
const notification = {
|
||||
title: 'Notification with image',
|
||||
body: 'Short message plus a custom image',
|
||||
icon: 'https://raw.githubusercontent.com/electron/electron-api-demos/v2.0.2/assets/img/programming.png'
|
||||
}
|
||||
const notificationButton = document.getElementById('advanced-noti')
|
||||
|
||||
notificationButton.addEventListener('click', () => {
|
||||
const myNotification = new window.Notification(notification.title, notification)
|
||||
|
||||
myNotification.onclick = () => {
|
||||
console.log('Notification clicked')
|
||||
}
|
||||
})
|
|
@ -15,7 +15,7 @@
|
|||
|
||||
<p>
|
||||
Open the
|
||||
<a href="https://electronjs.org/docs/api/tray">
|
||||
<a href="https://www.electronjs.org/docs/latest/api/tray">
|
||||
full API documentation
|
||||
</a>
|
||||
in your browser.
|
||||
|
@ -29,7 +29,7 @@
|
|||
On Linux distributions that only have app indicator support, users
|
||||
will need to install <code>libappindicator1</code> to make the
|
||||
tray icon work. See the
|
||||
<a href="https://electronjs.org/docs/api/tray">
|
||||
<a href="https://www.electronjs.org/docs/latest/api/tray">
|
||||
full API documentation
|
||||
</a>
|
||||
for more details about using Tray on Linux.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
const { app, BrowserWindow } = require('electron')
|
||||
const path = require('path')
|
||||
const path = require('node:path')
|
||||
|
||||
function createWindow () {
|
||||
const win = new BrowserWindow({
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// Retrieve information about screen size, displays, cursor position, etc.
|
||||
//
|
||||
// For more info, see:
|
||||
// https://electronjs.org/docs/api/screen
|
||||
// https://www.electronjs.org/docs/latest/api/screen
|
||||
|
||||
const { app, BrowserWindow } = require('electron')
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
const { app, BrowserWindow, ipcMain, clipboard } = require('electron')
|
||||
const path = require('path')
|
||||
const path = require('node:path')
|
||||
|
||||
let mainWindow = null
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
const { app, BrowserWindow, ipcMain, clipboard } = require('electron')
|
||||
const path = require('path')
|
||||
const path = require('node:path')
|
||||
|
||||
let mainWindow = null
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
<p>These methods allow you to set and unset the protocols your app should be the default app for. Similar to when a
|
||||
browser asks to be your default for viewing web pages.</p>
|
||||
|
||||
<p>Open the <a href="https://www.electronjs.org/docs/api/protocol">full protocol API documentation</a> in your
|
||||
<p>Open the <a href="https://www.electronjs.org/docs/latest/api/protocol">full protocol API documentation</a> in your
|
||||
browser.</p>
|
||||
|
||||
-----
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// Modules to control application life and create native browser window
|
||||
const { app, BrowserWindow, ipcMain, shell, dialog } = require('electron')
|
||||
const path = require('path')
|
||||
const path = require('node:path')
|
||||
|
||||
let mainWindow
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
</div>
|
||||
<p>The main process <code>app</code> module can be used to get the path at which your app is located on the user's computer.</p>
|
||||
<p>In this example, to get that information from the renderer process, we use the <code>ipc</code> module to send a message to the main process requesting the app's path.</p>
|
||||
<p>See the <a id="electron-docs" href="https://electronjs.org/docs/api/app">app module documentation<span class="u-visible-to-screen-reader">(opens in new window)</span></a> for more.</p>
|
||||
<p>See the <a id="electron-docs" href="https://www.electronjs.org/docs/latest/api/app">app module documentation<span class="u-visible-to-screen-reader">(opens in new window)</span></a> for more.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -1,5 +1,34 @@
|
|||
const { app, ipcMain } = require('electron')
|
||||
const { app, BrowserWindow, ipcMain, shell } = require('electron')
|
||||
|
||||
ipcMain.on('get-app-path', (event) => {
|
||||
event.sender.send('got-app-path', app.getAppPath())
|
||||
let mainWindow = null
|
||||
|
||||
ipcMain.handle('get-app-path', (event) => app.getAppPath())
|
||||
|
||||
function createWindow () {
|
||||
const windowOptions = {
|
||||
width: 600,
|
||||
height: 400,
|
||||
title: 'Get app information',
|
||||
webPreferences: {
|
||||
contextIsolation: false,
|
||||
nodeIntegration: true
|
||||
}
|
||||
}
|
||||
|
||||
mainWindow = new BrowserWindow(windowOptions)
|
||||
mainWindow.loadFile('index.html')
|
||||
|
||||
mainWindow.on('closed', () => {
|
||||
mainWindow = null
|
||||
})
|
||||
|
||||
// Open external links in the default browser
|
||||
mainWindow.webContents.on('will-navigate', (event, url) => {
|
||||
event.preventDefault()
|
||||
shell.openExternal(url)
|
||||
})
|
||||
}
|
||||
|
||||
app.whenReady().then(() => {
|
||||
createWindow()
|
||||
})
|
||||
|
|
|
@ -1,19 +1,9 @@
|
|||
const { ipcRenderer, shell } = require('electron')
|
||||
const { ipcRenderer } = require('electron')
|
||||
|
||||
const appInfoBtn = document.getElementById('app-info')
|
||||
const electronDocLink = document.querySelectorAll('a[href]')
|
||||
|
||||
appInfoBtn.addEventListener('click', () => {
|
||||
ipcRenderer.send('get-app-path')
|
||||
})
|
||||
|
||||
ipcRenderer.on('got-app-path', (event, path) => {
|
||||
appInfoBtn.addEventListener('click', async () => {
|
||||
const path = await ipcRenderer.invoke('get-app-path')
|
||||
const message = `This app is located at: ${path}`
|
||||
document.getElementById('got-app-info').innerHTML = message
|
||||
})
|
||||
|
||||
electronDocLink.addEventListener('click', (e) => {
|
||||
e.preventDefault()
|
||||
const url = e.target.getAttribute('href')
|
||||
shell.openExternal(url)
|
||||
})
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
</div>
|
||||
<p>The <code>process</code> module is built into Node.js (therefore you can use this in both the main and renderer processes) and in Electron apps this object has a few more useful properties on it.</p>
|
||||
<p>The example below gets the version of Electron in use by the app.</p>
|
||||
<p>See the <a href="https://electronjs.org/docs/api/process">process documentation <span>(opens in new window)</span></a> for more.</p>
|
||||
<p>See the <a href="https://www.electronjs.org/docs/latest/api/process">process documentation <span>(opens in new window)</span></a> for more.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
const { app, BrowserWindow } = require('electron')
|
||||
const { app, BrowserWindow, shell } = require('electron')
|
||||
|
||||
let mainWindow = null
|
||||
|
||||
|
@ -8,6 +8,7 @@ function createWindow () {
|
|||
height: 400,
|
||||
title: 'Get version information',
|
||||
webPreferences: {
|
||||
contextIsolation: false,
|
||||
nodeIntegration: true
|
||||
}
|
||||
}
|
||||
|
@ -18,6 +19,12 @@ function createWindow () {
|
|||
mainWindow.on('closed', () => {
|
||||
mainWindow = null
|
||||
})
|
||||
|
||||
// Open external links in the default browser
|
||||
mainWindow.webContents.on('will-navigate', (event, url) => {
|
||||
event.preventDefault()
|
||||
shell.openExternal(url)
|
||||
})
|
||||
}
|
||||
|
||||
app.whenReady().then(() => {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
const { app, BrowserWindow } = require('electron')
|
||||
const path = require('path')
|
||||
const path = require('node:path')
|
||||
|
||||
const createWindow = () => {
|
||||
const win = new BrowserWindow({
|
||||
|
|
|
@ -1,26 +0,0 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
</head>
|
||||
<body>
|
||||
<div>
|
||||
<div>
|
||||
<h1>Create a frameless window</h1>
|
||||
<i>Supports: Win, macOS, Linux <span>|</span> Process: Main</i>
|
||||
<div>
|
||||
<p>A frameless window is a window that has no <i>"chrome"</i>,
|
||||
such as toolbars, title bars, status bars, borders, etc. You can make
|
||||
a browser window frameless by setting
|
||||
<code>frame</code> to <code>false</code> when creating the window.</p>
|
||||
<div>
|
||||
<button id="frameless-window">View Demo</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
<script>
|
||||
require('./renderer.js')
|
||||
</script>
|
||||
</html>
|
|
@ -1,22 +0,0 @@
|
|||
const { app, BrowserWindow, ipcMain } = require('electron')
|
||||
|
||||
ipcMain.on('create-frameless-window', (event, { url }) => {
|
||||
const win = new BrowserWindow({ frame: false })
|
||||
win.loadURL(url)
|
||||
})
|
||||
|
||||
function createWindow () {
|
||||
const mainWindow = new BrowserWindow({
|
||||
width: 600,
|
||||
height: 400,
|
||||
title: 'Create a frameless window',
|
||||
webPreferences: {
|
||||
nodeIntegration: true
|
||||
}
|
||||
})
|
||||
mainWindow.loadFile('index.html')
|
||||
}
|
||||
|
||||
app.whenReady().then(() => {
|
||||
createWindow()
|
||||
})
|
|
@ -1,8 +0,0 @@
|
|||
const { ipcRenderer } = require('electron')
|
||||
|
||||
const newWindowBtn = document.getElementById('frameless-window')
|
||||
|
||||
newWindowBtn.addEventListener('click', () => {
|
||||
const url = 'data:text/html,<h2>Hello World!</h2><a id="close" href="javascript:window.close()">Close this Window</a>'
|
||||
ipcRenderer.send('create-frameless-window', { url })
|
||||
})
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
<p>
|
||||
Open the
|
||||
<a href="https://electronjs.org/docs/api/browser-window">
|
||||
<a href="https://www.electronjs.org/docs/latest/api/browser-window">
|
||||
full API documentation (opens in new window)
|
||||
</a>
|
||||
in your browser.
|
||||
|
@ -59,7 +59,7 @@
|
|||
|
||||
<p>
|
||||
For more details, see the
|
||||
<a href="https://electronjs.org/docs/tutorial/window-customization/">
|
||||
<a href="https://www.electronjs.org/docs/latest/tutorial/window-customization">
|
||||
Window Customization
|
||||
|
||||
</a>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// Modules to control application life and create native browser window
|
||||
const { app, BrowserWindow, ipcMain } = require('electron')
|
||||
const { app, BrowserWindow, ipcMain, shell } = require('electron')
|
||||
|
||||
ipcMain.on('create-frameless-window', (event, { url }) => {
|
||||
const win = new BrowserWindow({ frame: false })
|
||||
|
@ -12,12 +12,19 @@ function createWindow () {
|
|||
width: 800,
|
||||
height: 600,
|
||||
webPreferences: {
|
||||
contextIsolation: false,
|
||||
nodeIntegration: true
|
||||
}
|
||||
})
|
||||
|
||||
// and load the index.html of the app.
|
||||
mainWindow.loadFile('index.html')
|
||||
|
||||
// Open external links in the default browser
|
||||
mainWindow.webContents.on('will-navigate', (event, url) => {
|
||||
event.preventDefault()
|
||||
shell.openExternal(url)
|
||||
})
|
||||
}
|
||||
|
||||
// This method will be called when Electron has finished
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
<p>
|
||||
Open the
|
||||
<a href="https://electronjs.org/docs/api/browser-window">
|
||||
<a href="https://www.electronjs.org/docs/latest/api/browser-window">
|
||||
full API documentation (opens in new window)
|
||||
</a>
|
||||
in your browser.
|
||||
|
@ -47,7 +47,7 @@
|
|||
There are a lot of methods for controlling the state of the window
|
||||
such as the size, location, and focus status as well as events to
|
||||
listen to for window changes. Visit the
|
||||
<a href="https://electronjs.org/docs/api/browser-window">
|
||||
<a href="https://www.electronjs.org/docs/latest/api/browser-window">
|
||||
documentation (opens in new window)
|
||||
</a>
|
||||
for the full list.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// Modules to control application life and create native browser window
|
||||
const { app, BrowserWindow, ipcMain } = require('electron')
|
||||
const { app, BrowserWindow, ipcMain, shell } = require('electron')
|
||||
|
||||
ipcMain.on('create-demo-window', (event) => {
|
||||
const win = new BrowserWindow({ width: 400, height: 275 })
|
||||
|
@ -22,12 +22,19 @@ function createWindow () {
|
|||
width: 800,
|
||||
height: 600,
|
||||
webPreferences: {
|
||||
contextIsolation: false,
|
||||
nodeIntegration: true
|
||||
}
|
||||
})
|
||||
|
||||
// and load the index.html of the app.
|
||||
mainWindow.loadFile('index.html')
|
||||
|
||||
// Open external links in the default browser
|
||||
mainWindow.webContents.on('will-navigate', (event, url) => {
|
||||
event.preventDefault()
|
||||
shell.openExternal(url)
|
||||
})
|
||||
}
|
||||
|
||||
// This method will be called when Electron has finished
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
const { shell, ipcRenderer } = require('electron')
|
||||
const { ipcRenderer } = require('electron')
|
||||
|
||||
const manageWindowBtn = document.getElementById('manage-window')
|
||||
|
||||
const links = document.querySelectorAll('a[href]')
|
||||
|
||||
ipcRenderer.on('bounds-changed', (event, bounds) => {
|
||||
const manageWindowReply = document.getElementById('manage-window-reply')
|
||||
const message = `Size: ${bounds.size} Position: ${bounds.position}`
|
||||
|
@ -13,13 +11,3 @@ ipcRenderer.on('bounds-changed', (event, bounds) => {
|
|||
manageWindowBtn.addEventListener('click', (event) => {
|
||||
ipcRenderer.send('create-demo-window')
|
||||
})
|
||||
|
||||
Array.prototype.forEach.call(links, (link) => {
|
||||
const url = link.getAttribute('href')
|
||||
if (url.indexOf('http') === 0) {
|
||||
link.addEventListener('click', (e) => {
|
||||
e.preventDefault()
|
||||
shell.openExternal(url)
|
||||
})
|
||||
}
|
||||
})
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
<h3>Supports: Win, macOS, Linux <span>|</span> Process: Main</h3>
|
||||
<button id="new-window">View Demo</button>
|
||||
<p>The <code>BrowserWindow</code> module gives you the ability to create new windows in your app.</p>
|
||||
<p>There are a lot of options when creating a new window. A few are in this demo, but visit the <a id="browser-window-link" href="">documentation<span>(opens in new window)</span></a>
|
||||
<p>There are a lot of options when creating a new window. A few are in this demo, but visit the <a href="https://www.electronjs.org/docs/latest/api/browser-window">documentation<span>(opens in new window)</span></a>
|
||||
<div>
|
||||
<h2>ProTip</h2>
|
||||
<strong>Use an invisible browser window to run background tasks.</strong>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// Modules to control application life and create native browser window
|
||||
const { app, BrowserWindow, ipcMain } = require('electron')
|
||||
const { app, BrowserWindow, ipcMain, shell } = require('electron')
|
||||
|
||||
ipcMain.on('new-window', (event, { url, width, height }) => {
|
||||
const win = new BrowserWindow({ width, height })
|
||||
|
@ -12,12 +12,19 @@ function createWindow () {
|
|||
width: 800,
|
||||
height: 600,
|
||||
webPreferences: {
|
||||
contextIsolation: false,
|
||||
nodeIntegration: true
|
||||
}
|
||||
})
|
||||
|
||||
// and load the index.html of the app.
|
||||
mainWindow.loadFile('index.html')
|
||||
|
||||
// Open external links in the default browser
|
||||
mainWindow.webContents.on('will-navigate', (event, url) => {
|
||||
event.preventDefault()
|
||||
shell.openExternal(url)
|
||||
})
|
||||
}
|
||||
|
||||
// This method will be called when Electron has finished
|
||||
|
|
|
@ -1,14 +1,8 @@
|
|||
const { shell, ipcRenderer } = require('electron')
|
||||
const { ipcRenderer } = require('electron')
|
||||
|
||||
const newWindowBtn = document.getElementById('new-window')
|
||||
const link = document.getElementById('browser-window-link')
|
||||
|
||||
newWindowBtn.addEventListener('click', (event) => {
|
||||
const url = 'https://electronjs.org'
|
||||
ipcRenderer.send('new-window', { url, width: 400, height: 320 })
|
||||
})
|
||||
|
||||
link.addEventListener('click', (e) => {
|
||||
e.preventDefault()
|
||||
shell.openExternal('https://electronjs.org/docs/api/browser-window')
|
||||
})
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
<p>
|
||||
Open the
|
||||
<a href="https://electronjs.org/docs/api/browser-window">
|
||||
<a href="https://www.electronjs.org/docs/latest/api/browser-window">
|
||||
full API documentation (opens in new window)
|
||||
</a>
|
||||
in your browser.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// Modules to control application life and create native browser window
|
||||
const { app, BrowserWindow, ipcMain } = require('electron')
|
||||
const { app, BrowserWindow, ipcMain, shell } = require('electron')
|
||||
|
||||
function createWindow () {
|
||||
// Create the browser window.
|
||||
|
@ -7,6 +7,7 @@ function createWindow () {
|
|||
width: 800,
|
||||
height: 600,
|
||||
webPreferences: {
|
||||
contextIsolation: false,
|
||||
nodeIntegration: true
|
||||
}
|
||||
})
|
||||
|
@ -14,6 +15,12 @@ function createWindow () {
|
|||
// and load the index.html of the app.
|
||||
mainWindow.loadFile('index.html')
|
||||
|
||||
// Open external links in the default browser
|
||||
mainWindow.webContents.on('will-navigate', (event, url) => {
|
||||
event.preventDefault()
|
||||
shell.openExternal(url)
|
||||
})
|
||||
|
||||
let demoWindow
|
||||
ipcMain.on('show-demo-window', () => {
|
||||
if (demoWindow) {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
const { shell, ipcRenderer } = require('electron')
|
||||
const { ipcRenderer } = require('electron')
|
||||
|
||||
const listenToWindowBtn = document.getElementById('listen-to-window')
|
||||
const focusModalBtn = document.getElementById('focus-on-modal-window')
|
||||
|
@ -25,15 +25,3 @@ ipcRenderer.on('window-blur', showFocusBtn)
|
|||
listenToWindowBtn.addEventListener('click', () => {
|
||||
ipcRenderer.send('show-demo-window')
|
||||
})
|
||||
|
||||
const links = document.querySelectorAll('a[href]')
|
||||
|
||||
Array.prototype.forEach.call(links, (link) => {
|
||||
const url = link.getAttribute('href')
|
||||
if (url.indexOf('http') === 0) {
|
||||
link.addEventListener('click', (e) => {
|
||||
e.preventDefault()
|
||||
shell.openExternal(url)
|
||||
})
|
||||
}
|
||||
})
|
||||
|
|
|
@ -110,7 +110,7 @@ const driver = new webdriver.Builder()
|
|||
})
|
||||
.forBrowser('chrome') // note: use .forBrowser('electron') for selenium-webdriver <= 3.6.0
|
||||
.build()
|
||||
driver.get('http://www.google.com')
|
||||
driver.get('https://www.google.com')
|
||||
driver.findElement(webdriver.By.name('q')).sendKeys('webdriver')
|
||||
driver.findElement(webdriver.By.name('btnG')).click()
|
||||
driver.wait(() => {
|
||||
|
|
|
@ -91,7 +91,7 @@ contextBridge.exposeInMainWorld('electronAPI', {
|
|||
|
||||
You can create a `renderer.d.ts` declaration file and globally augment the `Window` interface:
|
||||
|
||||
```typescript title='renderer.d.ts'
|
||||
```typescript title='renderer.d.ts' @ts-noisolate
|
||||
export interface IElectronAPI {
|
||||
loadPreferences: () => Promise<void>,
|
||||
}
|
||||
|
@ -105,7 +105,7 @@ declare global {
|
|||
|
||||
Doing so will ensure that the TypeScript compiler will know about the `electronAPI` property on your global `window` object when writing scripts in your renderer process:
|
||||
|
||||
```typescript title='renderer.ts' @ts-nocheck
|
||||
```typescript title='renderer.ts'
|
||||
window.electronAPI.loadPreferences()
|
||||
```
|
||||
|
||||
|
|
|
@ -16,12 +16,13 @@ check out our [Electron Versioning](latest/tutorial/electron-versioning.md) doc.
|
|||
|
||||
| Electron | Alpha | Beta | Stable | EOL | Chrome | Node | Supported |
|
||||
| ------- | ----- | ------- | ------ | ------ | ---- | ---- | ---- |
|
||||
| 27.0.0 | 2023-Aug-17 | 2023-Sep-13 | 2023-Oct-10 | TBD | M118 | TBD | ✅ |
|
||||
| 28.0.0 | 2023-Oct-11 | 2023-Nov-6 | 2023-Dec-5 | TBD | M120 | TBD | ✅ |
|
||||
| 27.0.0 | 2023-Aug-17 | 2023-Sep-13 | 2023-Oct-10 | 2024-Apr-16 | M118 | v18.17 | ✅ |
|
||||
| 26.0.0 | 2023-Jun-01 | 2023-Jun-27 | 2023-Aug-15 | 2024-Feb-27 | M116 | v18.16 | ✅ |
|
||||
| 25.0.0 | 2023-Apr-10 | 2023-May-02 | 2023-May-30 | 2024-Jan-02 | M114 | v18.15 | ✅ |
|
||||
| 24.0.0 | 2023-Feb-09 | 2023-Mar-07 | 2023-Apr-04 | 2023-Oct-10 | M112 | v18.14 | ✅ |
|
||||
| 24.0.0 | 2023-Feb-09 | 2023-Mar-07 | 2023-Apr-04 | 2023-Oct-10 | M112 | v18.14 | 🚫 |
|
||||
| 23.0.0 | 2022-Dec-01 | 2023-Jan-10 | 2023-Feb-07 | 2023-Aug-15 | M110 | v18.12 | 🚫 |
|
||||
| 22.0.0 | 2022-Sep-29 | 2022-Oct-25 | 2022-Nov-29 | 2023-Oct-10 | M108 | v16.17 | ✅ |
|
||||
| 22.0.0 | 2022-Sep-29 | 2022-Oct-25 | 2022-Nov-29 | 2023-Oct-10 | M108 | v16.17 | 🚫 |
|
||||
| 21.0.0 | 2022-Aug-04 | 2022-Aug-30 | 2022-Sep-27 | 2023-Apr-04 | M106 | v16.16 | 🚫 |
|
||||
| 20.0.0 | 2022-May-26 | 2022-Jun-21 | 2022-Aug-02 | 2023-Feb-07 | M104 | v16.15 | 🚫 |
|
||||
| 19.0.0 | 2022-Mar-31 | 2022-Apr-26 | 2022-May-24 | 2022-Nov-29 | M102 | v16.14 | 🚫 |
|
||||
|
@ -51,7 +52,7 @@ check out our [Electron Versioning](latest/tutorial/electron-versioning.md) doc.
|
|||
|
||||
**Historical changes:**
|
||||
|
||||
* Since Electron 5, Electron has been publicizing its release dates ([see blog post](https://electronjs.org/blog/electron-5-0-timeline)).
|
||||
* Since Electron 5, Electron has been publicizing its release dates ([see blog post](https://www.electronjs.org/blog/electron-5-0-timeline)).
|
||||
* Since Electron 6, Electron major versions have been targeting every other Chromium major version. Each Electron stable should happen on the same day as Chrome stable ([see blog post](https://www.electronjs.org/blog/12-week-cadence)).
|
||||
* Since Electron 16, Electron has been releasing major versions on an 8-week cadence in accordance to Chrome's change to a 4-week release cadence ([see blog post](https://www.electronjs.org/blog/8-week-cadence)).
|
||||
|
||||
|
|
|
@ -71,6 +71,6 @@ Are you getting stuck anywhere? Here are a few links to places to look:
|
|||
[chromium]: https://www.chromium.org/
|
||||
[discord]: https://discord.gg/electronjs
|
||||
[examples]: latest/tutorial/examples.md
|
||||
[fiddle]: https://electronjs.org/fiddle
|
||||
[fiddle]: https://www.electronjs.org/fiddle
|
||||
[issue-tracker]: https://github.com/electron/electron/issues
|
||||
[node]: https://nodejs.org/
|
||||
|
|
|
@ -428,7 +428,7 @@ function createWindow () {
|
|||
For the purposes of the tutorial, it's important to note that the `click` handler
|
||||
sends a message (either `1` or `-1`) to the renderer process through the `update-counter` channel.
|
||||
|
||||
```javascript @ts-nocheck
|
||||
```javascript @ts-type={mainWindow:Electron.BrowserWindow}
|
||||
click: () => mainWindow.webContents.send('update-counter', -1)
|
||||
```
|
||||
|
||||
|
@ -508,13 +508,13 @@ To tie it all together, we'll create an interface in the loaded HTML file that c
|
|||
Finally, to make the values update in the HTML document, we'll add a few lines of DOM manipulation
|
||||
so that the value of the `#counter` element is updated whenever we fire an `update-counter` event.
|
||||
|
||||
```javascript title='renderer.js (Renderer Process)' @ts-nocheck
|
||||
```javascript title='renderer.js (Renderer Process)' @ts-window-type={electronAPI:{onUpdateCounter:(callback:(event:Electron.IpcRendererEvent,value:number)=>void)=>void}}
|
||||
const counter = document.getElementById('counter')
|
||||
|
||||
window.electronAPI.onUpdateCounter((_event, value) => {
|
||||
const oldValue = Number(counter.innerText)
|
||||
const newValue = oldValue + value
|
||||
counter.innerText = newValue
|
||||
counter.innerText = newValue.toString()
|
||||
})
|
||||
```
|
||||
|
||||
|
@ -531,13 +531,13 @@ We can demonstrate this with slight modifications to the code from the previous
|
|||
renderer process, use the `event` parameter to send a reply back to the main process through the
|
||||
`counter-value` channel.
|
||||
|
||||
```javascript title='renderer.js (Renderer Process)' @ts-nocheck
|
||||
```javascript title='renderer.js (Renderer Process)' @ts-window-type={electronAPI:{onUpdateCounter:(callback:(event:Electron.IpcRendererEvent,value:number)=>void)=>void}}
|
||||
const counter = document.getElementById('counter')
|
||||
|
||||
window.electronAPI.onUpdateCounter((event, value) => {
|
||||
const oldValue = Number(counter.innerText)
|
||||
const newValue = oldValue + value
|
||||
counter.innerText = newValue
|
||||
counter.innerText = newValue.toString()
|
||||
event.sender.send('counter-value', newValue)
|
||||
})
|
||||
```
|
||||
|
|
|
@ -133,7 +133,7 @@ app.whenReady().then(async () => {
|
|||
Then, in your preload scripts you receive the port through IPC and set up the
|
||||
listeners.
|
||||
|
||||
```js title='preloadMain.js and preloadSecondary.js (Preload scripts)' @ts-nocheck
|
||||
```js title='preloadMain.js and preloadSecondary.js (Preload scripts)' @ts-window-type={electronMessagePort:MessagePort}
|
||||
const { ipcRenderer } = require('electron')
|
||||
|
||||
ipcRenderer.on('port', e => {
|
||||
|
@ -155,7 +155,7 @@ That means window.electronMessagePort is globally available and you can call
|
|||
`postMessage` on it from anywhere in your app to send a message to the other
|
||||
renderer.
|
||||
|
||||
```js title='renderer.js (Renderer Process)' @ts-nocheck
|
||||
```js title='renderer.js (Renderer Process)' @ts-window-type={electronMessagePort:MessagePort}
|
||||
// elsewhere in your code to send a message to the other renderers message handler
|
||||
window.electronMessagePort.postMessage('ping')
|
||||
```
|
||||
|
|
Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше
Загрузка…
Ссылка в новой задаче