From 6280cd99e081695c327ed884c629b530f1a39689 Mon Sep 17 00:00:00 2001
From: Samuel Attard
Date: Sat, 2 Oct 2021 02:02:16 -0700
Subject: [PATCH] =?UTF-8?q?feat:=20New=20Crowdin=20translations=20(auto-me?=
=?UTF-8?q?rged=20=F0=9F=A4=96)=20(#2066)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
content/de-DE/docs/api/app.md | 1 +
content/de-DE/docs/api/browser-window.md | 2 +-
content/de-DE/docs/api/dialog.md | 2 +
content/de-DE/docs/api/session.md | 144 ++++++++++++++++-
.../de-DE/docs/api/structures/hid-device.md | 8 +
content/de-DE/docs/api/web-contents.md | 5 +-
content/es-ES/docs/api/app.md | 20 +--
content/es-ES/docs/api/browser-window.md | 4 +-
content/es-ES/docs/api/dialog.md | 4 +-
content/es-ES/docs/api/menu-item.md | 6 +-
content/es-ES/docs/api/session.md | 150 +++++++++++++++++-
.../es-ES/docs/api/structures/hid-device.md | 8 +
content/es-ES/docs/api/web-contents.md | 21 +--
content/es-ES/docs/api/web-frame-main.md | 6 +-
content/es-ES/docs/api/web-request.md | 16 +-
content/es-ES/docs/api/window-open.md | 11 +-
.../es-ES/docs/tutorial/context-isolation.md | 10 +-
.../es-ES/docs/tutorial/debugging-vscode.md | 4 +-
.../es-ES/docs/tutorial/electron-timelines.md | 34 ++--
content/es-ES/docs/tutorial/performance.md | 6 +-
content/es-ES/docs/tutorial/progress-bar.md | 2 +-
content/es-ES/docs/tutorial/sandbox.md | 2 +-
content/fr-FR/docs/api/app.md | 1 +
content/fr-FR/docs/api/browser-window.md | 2 +-
content/fr-FR/docs/api/dialog.md | 2 +
content/fr-FR/docs/api/session.md | 144 ++++++++++++++++-
.../fr-FR/docs/api/structures/hid-device.md | 8 +
content/fr-FR/docs/api/web-contents.md | 5 +-
content/ja-JP/docs/api/app.md | 1 +
content/ja-JP/docs/api/browser-window.md | 2 +-
content/ja-JP/docs/api/dialog.md | 2 +
content/ja-JP/docs/api/session.md | 144 ++++++++++++++++-
.../ja-JP/docs/api/structures/hid-device.md | 8 +
content/ja-JP/docs/api/web-contents.md | 5 +-
.../debugging-instructions-macos.md | 2 +-
content/ja-JP/docs/tutorial/devices.md | 24 +--
content/pt-BR/docs/api/app.md | 1 +
content/pt-BR/docs/api/browser-window.md | 2 +-
content/pt-BR/docs/api/dialog.md | 2 +
content/pt-BR/docs/api/session.md | 144 ++++++++++++++++-
.../pt-BR/docs/api/structures/hid-device.md | 8 +
content/pt-BR/docs/api/web-contents.md | 5 +-
content/ru-RU/docs/api/app.md | 1 +
content/ru-RU/docs/api/browser-window.md | 2 +-
content/ru-RU/docs/api/dialog.md | 2 +
content/ru-RU/docs/api/session.md | 144 ++++++++++++++++-
.../ru-RU/docs/api/structures/hid-device.md | 8 +
content/ru-RU/docs/api/web-contents.md | 5 +-
content/zh-CN/docs/api/app.md | 6 +-
content/zh-CN/docs/api/browser-window.md | 2 +-
content/zh-CN/docs/api/dialog.md | 2 +
content/zh-CN/docs/api/session.md | 144 ++++++++++++++++-
.../zh-CN/docs/api/structures/hid-device.md | 8 +
content/zh-CN/docs/api/web-contents.md | 7 +-
54 files changed, 1199 insertions(+), 110 deletions(-)
create mode 100644 content/de-DE/docs/api/structures/hid-device.md
create mode 100644 content/es-ES/docs/api/structures/hid-device.md
create mode 100644 content/fr-FR/docs/api/structures/hid-device.md
create mode 100644 content/ja-JP/docs/api/structures/hid-device.md
create mode 100644 content/pt-BR/docs/api/structures/hid-device.md
create mode 100644 content/ru-RU/docs/api/structures/hid-device.md
create mode 100644 content/zh-CN/docs/api/structures/hid-device.md
diff --git a/content/de-DE/docs/api/app.md b/content/de-DE/docs/api/app.md
index 300c87c19a20e..8354a58c69c44 100644
--- a/content/de-DE/docs/api/app.md
+++ b/content/de-DE/docs/api/app.md
@@ -222,6 +222,7 @@ Kehrt zurück:
* `certificate` [Certificate](structures/certificate.md)
* `callback` Function
* `isTrusted` Boolean - Gibt an ob das Zertifikat als vertrauenswürdig angesehen werden soll
+* `isMainFrame` Boolean
Emittiert wenn die Verifizierung des `certificate` für die `url` fehlschlägt, um dem Zertifikat dennoch zu vertrauen müssen die das normale Verhalten abschalten mit `event.preventDefault()` und `callback(true)` aufrufen.
diff --git a/content/de-DE/docs/api/browser-window.md b/content/de-DE/docs/api/browser-window.md
index e011da464f966..08c06892781d0 100644
--- a/content/de-DE/docs/api/browser-window.md
+++ b/content/de-DE/docs/api/browser-window.md
@@ -759,7 +759,7 @@ This will make a window maintain an aspect ratio. The extra size allows a develo
Consider a normal window with an HD video player and associated controls. Perhaps there are 15 pixels of controls on the left edge, 25 pixels of controls on the right edge and 50 pixels of controls below the player. In order to maintain a 16:9 aspect ratio (standard aspect ratio for HD @1920x1080) within the player itself we would call this function with arguments of 16/9 and
{ width: 40, height: 50 }. The second argument doesn't care where the extra width and height are within the content view--only that they exist. Sum any extra width and height areas you have within the overall content view.
-The aspect ratio is not respected when window is resized programmingly with APIs like `win.setSize`.
+The aspect ratio is not respected when window is resized programmatically with APIs like `win.setSize`.
#### `win.setBackgroundColor(backgroundColor)`
diff --git a/content/de-DE/docs/api/dialog.md b/content/de-DE/docs/api/dialog.md
index 88609985656c6..6dcea9f11b61b 100644
--- a/content/de-DE/docs/api/dialog.md
+++ b/content/de-DE/docs/api/dialog.md
@@ -187,6 +187,7 @@ The `filters` specifies an array of file types that can be displayed, see `dialo
* `title` String (optional) - Title of the message box, some platforms will not show it.
* `detail` String (optional) - Extra information of the message.
* `icon` ([NativeImage](native-image.md) | String) (optional)
+ * `textWidth` Integer (optional) _macOS_ - Custom width of the text in the message box.
* `cancelId` Integer (optional) - The index of the button to be used to cancel the dialog, via the `Esc` key. By default this is assigned to the first button with "cancel" or "no" as the label. If no such labeled buttons exist and this option is not set, `0` will be used as the return value.
* `noLink` Boolean (optional) - On Windows Electron will try to figure out which one of the `buttons` are common buttons (like "Cancel" or "Yes"), and show the others as command links in the dialog. This can make the dialog appear in the style of modern Windows apps. If you don't like this behavior, you can set `noLink` to `true`.
* `normalizeAccessKeys` Boolean (optional) - Normalize the keyboard access keys across platforms. Standard ist `false`. Enabling this assumes `&` is used in the button labels for the placement of the keyboard shortcut access key and labels will be converted so they work correctly on each platform, `&` characters are removed on macOS, converted to `_` on Linux, and left untouched on Windows. For example, a button label of `Vie&w` will be converted to `Vie_w` on Linux and `View` on macOS and can be selected via `Alt-W` on Windows and Linux.
@@ -211,6 +212,7 @@ The `browserWindow` argument allows the dialog to attach itself to a parent wind
* `checkboxLabel` String (optional) - If provided, the message box will include a checkbox with the given label.
* `checkboxChecked` Boolean (optional) - Initial checked state of the checkbox. Automatisch `false`.
* `icon` [NativeImage](native-image.md) (optional)
+ * `textWidth` Integer (optional) _macOS_ - Custom width of the text in the message box.
* `cancelId` Integer (optional) - The index of the button to be used to cancel the dialog, via the `Esc` key. By default this is assigned to the first button with "cancel" or "no" as the label. If no such labeled buttons exist and this option is not set, `0` will be used as the return value.
* `noLink` Boolean (optional) - On Windows Electron will try to figure out which one of the `buttons` are common buttons (like "Cancel" or "Yes"), and show the others as command links in the dialog. This can make the dialog appear in the style of modern Windows apps. If you don't like this behavior, you can set `noLink` to `true`.
* `normalizeAccessKeys` Boolean (optional) - Normalize the keyboard access keys across platforms. Standard ist `false`. Enabling this assumes `&` is used in the button labels for the placement of the keyboard shortcut access key and labels will be converted so they work correctly on each platform, `&` characters are removed on macOS, converted to `_` on Linux, and left untouched on Windows. For example, a button label of `Vie&w` will be converted to `Vie_w` on Linux and `View` on macOS and can be selected via `Alt-W` on Windows and Linux.
diff --git a/content/de-DE/docs/api/session.md b/content/de-DE/docs/api/session.md
index b0a22bce1c998..b25d661c7ea74 100644
--- a/content/de-DE/docs/api/session.md
+++ b/content/de-DE/docs/api/session.md
@@ -160,6 +160,91 @@ Kehrt zurück:
Emitted when a hunspell dictionary file download fails. For details on the failure you should collect a netlog and inspect the download request.
+#### Event: 'select-hid-device'
+
+Kehrt zurück:
+
+* `event` Event
+* `details` Objekt
+ * `deviceList` [HIDDevice[]](structures/hid-device.md)
+ * `frame` [WebFrameMain](web-frame-main.md)
+* `callback` Function
+ * `deviceId` String | null (optional)
+
+Emitted when a HID device needs to be selected when a call to `navigator.hid.requestDevice` is made. `callback` should be called with `deviceId` to be selected; passing no arguments to `callback` will cancel the request. Additionally, permissioning on `navigator.hid` can be further managed by using [ses.setPermissionCheckHandler(handler)](#sessetpermissioncheckhandlerhandler) and [ses.setDevicePermissionHandler(handler)`](#sessetdevicepermissionhandlerhandler).
+
+```javascript
+const { app, BrowserWindow } = require('electron')
+
+let win = null
+
+app.whenReady().then(() => {
+ win = new BrowserWindow()
+
+ win.webContents.session.setPermissionCheckHandler((webContents, permission, requestingOrigin, details) => {
+ if (permission === 'hid') {
+ // Add logic here to determine if permission should be given to allow HID selection
+ return true
+ }
+ return false
+ })
+
+ // Optionally, retrieve previously persisted devices from a persistent store
+ const grantedDevices = fetchGrantedDevices()
+
+ win.webContents.session.setDevicePermissionHandler((details) => {
+ if (new URL(details.origin).hostname === 'some-host' && details.deviceType === 'hid') {
+ if (details.device.vendorId === 123 && details.device.productId === 345) {
+ // Always allow this type of device (this allows skipping the call to `navigator.hid.requestDevice` first)
+ return true
+ }
+
+ // Search through the list of devices that have previously been granted permission
+ return grantedDevices.some((grantedDevice) => {
+ return grantedDevice.vendorId === details.device.vendorId &&
+ grantedDevice.productId === details.device.productId &&
+ grantedDevice.serialNumber && grantedDevice.serialNumber === details.device.serialNumber
+ })
+ }
+ return false
+ })
+
+ win.webContents.session.on('select-hid-device', (event, details, callback) => {
+ event.preventDefault()
+ const selectedDevice = details.deviceList.find((device) => {
+ return device.vendorId === '9025' && device.productId === '67'
+ })
+ callback(selectedPort?.deviceId)
+ })
+})
+```
+
+#### Event: 'hid-device-added'
+
+Kehrt zurück:
+
+* `event` Event
+* `details` Objekt
+ * `device` [HIDDevice[]](structures/hid-device.md)
+ * `frame` [WebFrameMain](web-frame-main.md)
+
+Emitted when a new HID device becomes available. For example, when a new USB device is plugged in.
+
+This event will only be emitted after `navigator.hid.requestDevice` has been called and `select-hid-device` has fired.
+
+#### Event: 'hid-device-removed'
+
+Kehrt zurück:
+
+* `event` Event
+* `details` Objekt
+ * `device` [HIDDevice[]](structures/hid-device.md)
+ * `frame` [WebFrameMain](web-frame-main.md)
+
+Emitted when a HID device has been removed. For example, this event will fire when a USB device is unplugged.
+
+This event will only be emitted after `navigator.hid.requestDevice` has been called and `select-hid-device` has fired.
+
#### Event: 'select-serial-port'
Kehrt zurück:
@@ -447,7 +532,7 @@ session.fromPartition('some-partition').setPermissionRequestHandler((webContents
* `handler` Funktion\ | null
* `webContents` ([WebContents](web-contents.md) | null) - WebContents checking the permission. Please note that if the request comes from a subframe you should use `requestingUrl` to check the request origin. All cross origin sub frames making permission checks will pass a `null` webContents to this handler, while certain other permission checks such as `notifications` checks will always pass `null`. You should use `embeddingOrigin` and `requestingOrigin` to determine what origin the owning frame and the requesting frame are on respectively.
- * `permission` String - Type of permission check. Valid values are `midiSysex`, `notifications`, `geolocation`, `media`,`mediaKeySystem`,`midi`, `pointerLock`, `fullscreen`, `openExternal`, or `serial`.
+ * `permission` String - Type of permission check. Valid values are `midiSysex`, `notifications`, `geolocation`, `media`,`mediaKeySystem`,`midi`, `pointerLock`, `fullscreen`, `openExternal`, `hid`, or `serial`.
* `requestingOrigin` String - The origin URL of the permission check
* `details` Object - Some properties are only available on certain permission types.
* `embeddingOrigin` String (optional) - The origin of the frame embedding the frame that made the permission check. Only set for cross-origin sub frames making permission checks.
@@ -470,6 +555,63 @@ session.fromPartition('some-partition').setPermissionCheckHandler((webContents,
})
```
+#### `ses.setDevicePermissionHandler(handler)`
+
+* `handler` Funktion\ | null
+ * `details` Objekt
+ * `deviceType` String - The type of device that permission is being requested on, can be `hid`.
+ * `origin` String - The origin URL of the device permission check.
+ * `device` [HIDDevice](structures/hid-device.md) - the device that permission is being requested for.
+ * `frame` [WebFrameMain](web-frame-main.md) - WebFrameMain checking the device permission.
+
+Sets the handler which can be used to respond to device permission checks for the `session`. Returning `true` will allow the device to be permitted and `false` will reject it. To clear the handler, call `setDevicePermissionHandler(null)`. This handler can be used to provide default permissioning to devices without first calling for permission to devices (eg via `navigator.hid.requestDevice`). If this handler is not defined, the default device permissions as granted through device selection (eg via `navigator.hid.requestDevice`) will be used. Additionally, the default behavior of Electron is to store granted device permision through the lifetime of the corresponding WebContents. If longer term storage is needed, a developer can store granted device permissions (eg when handling the `select-hid-device` event) and then read from that storage with `setDevicePermissionHandler`.
+
+```javascript
+const { app, BrowserWindow } = require('electron')
+
+let win = null
+
+app.whenReady().then(() => {
+ win = new BrowserWindow()
+
+ win.webContents.session.setPermissionCheckHandler((webContents, permission, requestingOrigin, details) => {
+ if (permission === 'hid') {
+ // Add logic here to determine if permission should be given to allow HID selection
+ return true
+ }
+ return false
+ })
+
+ // Optionally, retrieve previously persisted devices from a persistent store
+ const grantedDevices = fetchGrantedDevices()
+
+ win.webContents.session.setDevicePermissionHandler((details) => {
+ if (new URL(details.origin).hostname === 'some-host' && details.deviceType === 'hid') {
+ if (details.device.vendorId === 123 && details.device.productId === 345) {
+ // Always allow this type of device (this allows skipping the call to `navigator.hid.requestDevice` first)
+ return true
+ }
+
+ // Search through the list of devices that have previously been granted permission
+ return grantedDevices.some((grantedDevice) => {
+ return grantedDevice.vendorId === details.device.vendorId &&
+ grantedDevice.productId === details.device.productId &&
+ grantedDevice.serialNumber && grantedDevice.serialNumber === details.device.serialNumber
+ })
+ }
+ return false
+ })
+
+ win.webContents.session.on('select-hid-device', (event, details, callback) => {
+ event.preventDefault()
+ const selectedDevice = details.deviceList.find((device) => {
+ return device.vendorId === '9025' && device.productId === '67'
+ })
+ callback(selectedPort?.deviceId)
+ })
+})
+```
+
#### `ses.clearHostResolverCache()`
Returns `Promise` - Resolves when the operation is complete.
diff --git a/content/de-DE/docs/api/structures/hid-device.md b/content/de-DE/docs/api/structures/hid-device.md
new file mode 100644
index 0000000000000..fac2b6276a9df
--- /dev/null
+++ b/content/de-DE/docs/api/structures/hid-device.md
@@ -0,0 +1,8 @@
+# HIDDevice Object
+
+* `deviceId` String - Unique identifier for the device.
+* `name` String - Name of the device.
+* `vendorId` Integer - The USB vendor ID.
+* `productId` Integer - The USB product ID.
+* `serialNumber` String (optional) - The USB device serial number.
+* `guid` String (optional) - Unique identifier for the HID interface. A device may have multiple HID interfaces.
diff --git a/content/de-DE/docs/api/web-contents.md b/content/de-DE/docs/api/web-contents.md
index 6cc1bcc15d6fc..671f6906ef629 100644
--- a/content/de-DE/docs/api/web-contents.md
+++ b/content/de-DE/docs/api/web-contents.md
@@ -463,6 +463,7 @@ Kehrt zurück:
* `certificate` [Certificate](structures/certificate.md)
* `callback` Function
* `isTrusted` Boolean - Indicates whether the certificate can be considered trusted.
+* `isMainFrame` Boolean
Emitted when failed to verify the `certificate` for `url`.
@@ -570,6 +571,7 @@ Kehrt zurück:
* `params` Object
* `x` Integer - x Koordinate.
* `y` Integer - y Koordinate.
+ * `frame` WebFrameMain - Frame from which the context menu was invoked.
* `linkURL` String - URL of the link that encloses the node the context menu was invoked on.
* `linkText` String - Text associated with the link. May be an empty string if the contents of the link are an image.
* `pageURL` String - URL of the top level page that the context menu was invoked on.
@@ -1608,7 +1610,8 @@ End subscribing for frame presentation events.
#### `contents.startDrag(item)`
* `item` Objekt
- * `file` String[] | String - The path(s) to the file(s) being dragged.
+ * `file` String - The path to the file being dragged.
+ * `files` String[] (optional) - The paths to the files being dragged. (`files` will override `file` field)
* `icon` [NativeImage](native-image.md) | String - The image must be non-empty on macOS.
Sets the `item` as dragging item for current drag-drop operation, `file` is the absolute path of the file to be dragged, and `icon` is the image showing under the cursor when dragging.
diff --git a/content/es-ES/docs/api/app.md b/content/es-ES/docs/api/app.md
index 54a9345a336ed..39ee5bf142f07 100644
--- a/content/es-ES/docs/api/app.md
+++ b/content/es-ES/docs/api/app.md
@@ -222,6 +222,7 @@ Devuelve:
* `certificate` [certificate](structures/certificate.md)
* `callback` Función
* `isTrusted` Boleano - Si considera que el certificado como de confianza
+* `EsElFramePrincipal` Boolean
Emitido cuando falla la verificación de `certificate` por `url`, al confiar en el certificado usted debe prevenir el comportamiento con `event.preventDefault()` y llamar `callback(true)`.
@@ -582,7 +583,7 @@ Reescribe el nombre de la aplicación actual.
Devuelve `String` - Los parámetros regionales actuales de la aplicación, recopilados usando la biblioteca `l10n_util` de Chromium. Los posibles valores de retorno son documentados [aquí](https://source.chromium.org/chromium/chromium/src/+/master:ui/base/l10n/l10n_util.cc).
-Para establecer la locale, querrás usar un interruptor de línea de comandos al inicio de la aplicación, que puede encontrarse [aquí](command-line-switches.md).
+Para establecer el locale, querrás usar un interruptor de línea de comandos al inicio de la aplicación, que puede encontrarse [aquí](command-line-switches.md).
**Nota:** Al distribuir su aplicación empaquetada, también tiene que enviar las carpetas `locales`.
@@ -867,21 +868,20 @@ Importa el certificado en formato pkcs12 dentro del certificado de la plataforma
### `app.configureHostResolver(options)`
* `options` Object
- * `enableBuiltInResolver` Boolean (optional) - Whether the built-in host resolver is used in preference to getaddrinfo. When enabled, the built-in resolver will attempt to use the system's DNS settings to do DNS lookups itself. Activado por defecto en macOS, desactivado por defecto en Windows y Linux.
+ * `enableBuiltInResolver` Boolean (opcional) - Si el resolver de host integrado se utiliza en preferencia para getaddrinfo. Cuando está activado, el resolver integrado intentara usar las configuraciones DNS del sistema para hacer las consultas DNS por si mismo. Activado por defecto en macOS, desactivado por defecto en Windows y Linux.
* `secureDnsMode` String (opcional) - Puede ser "off", "automatic" o "secure". Configura el modo DNS-over-HTTP. Cuando es "off", las búsquedas DoH no se realizarán. Cuando es "automatic", las búsquedas DoH se realizarán primero si DoH está disponible, y las búsquedas DNS se realizarán como una reserva. Cuando es "secure", sólo se realizarán búsquedas DoH. Por defecto es "automatic".
- * `secureDnsServers` String[] (opcional) - Una lista de plantillas de servidor DNS-over-HTTP. Vea [RFC8484 § 3][] para más detalles sobre el formato de la plantilla. La mayoría de los servidores soportan el método POST; la plantilla para estos servidores es simplemente una URI. Note that for [some DNS providers][doh-providers], the resolver will automatically upgrade to DoH unless DoH is explicitly disabled, even if there are no DoH servers provided in this list.
- * `enableAdditionalDnsQueryTypes` Boolean (optional) - Controls whether additional DNS query types, e.g. HTTPS (DNS type 65) will be allowed besides the traditional A and AAAA queries when a request is being made via insecure DNS. Has no effect on Secure DNS which always allows additional types. Defaults to true.
+ * `secureDnsServers` String[] (opcional) - Una lista de plantillas de servidor DNS-over-HTTP. Vea [RFC8484 § 3][] para más detalles sobre el formato de la plantilla. La mayoría de los servidores soportan el método POST; la plantilla para estos servidores es simplemente una URI. Tenga en cuenta que para [algunos proveedores DNS ][doh-providers], el resolver actualizará automáticamente a DoH a menos que DoH este explícitamente desactivado, incluso si no hay servidores DoH proporcionados en esta lista.
+ * `enableAdditionalDnsQueryTypes` Boolean (opcional) - Controla si consultas DNS de tipos adicionales, p.e. HTTPS(DNS type 65) serán permitidas ademas de las tradicionales consultas A y AAAA cuando una solicitud esta siendo hecha a través de DNS inseguro. No tiene efecto en DNS seguro que siempre permite tipos adicionales. Defaults to true.
Configure la resolución de host (DNS y DNS-over-HTTPS). Por defecto, se utilizarán los siguientes resolutores en orden:
1. DNS-over-HTTPS, si [DNS provider supports it][doh-providers], luego
2. el resolutor integrado (activado sólo por defecto en macOS), luego
-3. the system's resolver (e.g. `getaddrinfo`).
+3. el resolver del sistema (p.e. `getaddrinfo`).
-This can be configured to either restrict usage of non-encrypted DNS (`secureDnsMode: "secure"`), or disable DNS-over-HTTPS (`secureDnsMode:
-"off"`). It is also possible to enable or disable the built-in resolver.
+Esto puede ser configurado tanto para restringir el uso de DNS no-encriptado (`secureDnsMode: "secure"`), o desactivar DNS-over-HTTPS (`secureDnsMode:"off"`). También es posible activar o desactivar el resolver incorporado.
-To disable insecure DNS, you can specify a `secureDnsMode` of `"secure"`. If you do so, you should make sure to provide a list of DNS-over-HTTPS servers to use, in case the user's DNS configuration does not include a provider that supports DoH.
+Para desactivar DNS inseguro, puede especificar `secureDnsMode` de `"secure"`. Si usted hace eso, debería asegurarse de proveer una lista de servidores DNS-overHTTPS para usar, en caso de que la configuración DNS del usuario no incluya un proveedor que soporte DoH.
```js
app.configureHostResolver({
@@ -1201,11 +1201,11 @@ A `Boolean` which when `true` indicates that the app is currently running under
You can use this property to prompt users to download the arm64 version of your application when they are running the x64 version under Rosetta incorrectly.
-**Deprecated:** This property is superceded by the `runningUnderARM64Translation` property which detects when the app is being translated to ARM64 in both macOS and Windows.
+**Obsoleto:** Esta propiedad es reemplazada por la propiedad `runningUnderARM64Translation` la cual detecta cuando la aplicación esta traducida a ARM64 tanto en macOS y Windows.
### `app.runningUnderARM64Translation` _Readonly_ _macOS_ _Windows_
-A `Boolean` which when `true` indicates that the app is currently running under an ARM64 translator (like the macOS [Rosetta Translator Environment](https://en.wikipedia.org/wiki/Rosetta_(software)) or Windows [WOW](https://en.wikipedia.org/wiki/Windows_on_Windows)).
+Un `Boolean` el cual cuando es `true` indica que la aplicación actualmente está ejecutándose bajo un traductor ARM64 (como el [Rosetta Translator Environment](https://en.wikipedia.org/wiki/Rosetta_(software)) de macOS o [WOW](https://en.wikipedia.org/wiki/Windows_on_Windows) de Windows).
You can use this property to prompt users to download the arm64 version of your application when they are running the x64 version under Rosetta incorrectly.
diff --git a/content/es-ES/docs/api/browser-window.md b/content/es-ES/docs/api/browser-window.md
index 9aa5db60a5533..987fc86a79429 100644
--- a/content/es-ES/docs/api/browser-window.md
+++ b/content/es-ES/docs/api/browser-window.md
@@ -223,7 +223,7 @@ Crea una nueva `BrowserWindow` con propiedades nativas como las establecidas por
* `bypassHeatCheck` - Bypass code caching heuristics but with lazy compilation
* `bypassHeatCheckAndEagerCompile` - Same as above except compilation is eager. Default policy is `code`.
* `enablePreferredSizeMode` Boolean (optional) - Whether to enable preferred size mode. The preferred size is the minimum size needed to contain the layout of the document—without requiring scrolling. Enabling this will cause the `preferred-size-changed` event to be emitted on the `WebContents` when the preferred size changes. Por defecto es `false`.
- * `titleBarOverlay` Object | Boolean (optional) - When using a frameless window in conjuction with `win.setWindowButtonVisibility(true)` on macOS or using a `titleBarStyle` so that the standard window controls ("traffic lights" on macOS) are visible, this property enables the Window Controls Overlay [JavaScript APIs][overlay-javascript-apis] and [CSS Environment Variables][overlay-css-env-vars]. Specifying `true` will result in an overlay with default system colors. Por defecto es `false`.
+ * `titleBarOverlay` Object | Boolean (opcional) - Cuando se usa una ventana sin marco en conjunción con `win.setWindowButtonVisibility(true)` en macOS o usando `titleBarStyle` para que los controles de la ventana estándar ("traffic lights" en macOS) estén visibles, esta propiedad activa el Window Controls Overlay [JavaScript APIs][overlay-javascript-apis] y [CSS Environment Variables][overlay-css-env-vars]. Specifying `true` will result in an overlay with default system colors. Por defecto es `false`.
* `color` String (optional) _Windows_ - The CSS color of the Window Controls Overlay when enabled. Default is the system color.
* `symbolColor` String (optional) _Windows_ - The CSS color of the symbols on the Window Controls Overlay when enabled. Default is the system color.
@@ -759,7 +759,7 @@ Esto hará que la ventana mantenga una relación de aspecto. El tamaño extra pe
Considere una ventana normal con un reproductor de video HD y los controles asociados. Quizá hay 15 pixeles de controles en el borde izquierdo, 25 pixeles de control en el borde derecho y 50 pixeles de control bajo el reproductor. In order to maintain a 16:9 aspect ratio (standard aspect ratio for HD @1920x1080) within the player itself we would call this function with arguments of 16/9 and
{ width: 40, height: 50 }. En el segundo argumento no importa donde están la anchura extra ni altura extra dentro de la vista del contenido, solo importa que existan. Suma cualquier áreas de ancho y alto adicionales que tengas dentro de la vista de contenido general.
-The aspect ratio is not respected when window is resized programmingly with APIs like `win.setSize`.
+La relación de aspecto no se respeta cuando la ventana se redimensiona programáticamente con APIs como `win.setSize`.
#### `win.setBackgroundColor(backgroundColor)`
diff --git a/content/es-ES/docs/api/dialog.md b/content/es-ES/docs/api/dialog.md
index 985e2be182f07..17608a3bff9cc 100644
--- a/content/es-ES/docs/api/dialog.md
+++ b/content/es-ES/docs/api/dialog.md
@@ -187,6 +187,7 @@ Los `filtros` especifican un arreglo de los tipos de archivos can pueden ser mos
* `title` Cadena (opcional) - Título del mensaje de la caja, algunas plataformas no se mostrarán.
* `detail` Cadena (opcional) - Información extra del mensaje.
* `icon` ([NativeImage](native-image.md) | String) (opcional)
+ * `textWidth` Integer (optional) _macOS_ - Custom width of the text in the message box.
* `cancelId` Íntegro (opcional) - El índice el botón a ser usado a cancelar el diálogo, por vía la llave `Esc`. Por defecto, esto es asignado a el primer botón con "cancelar" o "no" como una etiqueta. Si no existen tales botones etiquetados y esta opción no esta configurada, `0` será usada como el valor de retorno.
* `noLink` Boolean (opcional) - En Windows Electron se tratará de averiguar cuál de los `buttons` son botones comunes (como "Cancelar" o "Sí"), y muestra los otros como links de comandos en el diálogo. Esto puede hacer que el diálogo aparezca en el estilo de las aplicaciones modernas de Windows. Si no te gusta este comportamiento, puedes establecer `noLink` a `true`.
* `normalizeAccessKeys` Boolean (opcional) - Normalizar el acceso al teclado a través de las plataformas. Por defecto es `false`. Permitir esto asume que `&` es usado en las etiquetas de los botones para el colocamiento de los atajos de acceso de las teclas del teclado y las etiquetas serán convertidas para que funcionen correctamente en cada plataforma, `&` personajes serán eliminados de macOS, convertidos a `_` en Linux, y dejado intacto en Windows. Por ejemplo, una etiqueta de botón de `Vie&w` será convertida a `Vie_w` en Linux y `View` en macOS y puede ser seleccionado vía `Alt-W` en Windows y Linux.
@@ -205,12 +206,13 @@ El argumento de `browserWindow` permite el diálogo a adjuntarse a una ventana p
* `type` Cadena (opcional) - Puede ser `"none"`, `"info"`, `"error"`, `"question"` o `"warning"`. En Windows, `"question"` muestra el mismo icono que `"info"`, a menos que tu dispongas un icono usando la opción `"icon"`. En macOS, tanto `"warning"` como `"error"` muestran el mismo icono de peligro.
* `buttons` String[] (optional) - Array of texts for buttons. En Windows, un array vacío resultará en un botón con al etiqueta "OK".
* `defaultId` Íntegro (opcional) - El índice del botón en el arreglo de los botones, el cual será selecto por defecto cuando el mensaje de la caja se abra.
- * `signal` AbortSignal (optional) - Pass an instance of [AbortSignal][] to optionally close the message box, the message box will behave as if it was cancelled by the user. On macOS, `signal` does not work with message boxes that do not have a parent window, since those message boxes run synchronously due to platform limitations.
+ * `signal` AbortSignal (opcional) - Pasar un instancia de [AbortSignal][] a opcionalmente cerrar el cuadro de mensaje, el cuadro de mensaje se comportará como si fuera cancelado por el usuario. En macOS, `signal` no funciona con los cuadros de mensajes que no tengan una ventana padre, dado que esos cuadros de mensajes se ejecutan de forma sincrónica debido a las limitaciones de la plataforma.
* `title` Cadena (opcional) - Título del mensaje de la caja, algunas plataformas no se mostrarán.
* `detail` Cadena (opcional) - Información extra del mensaje.
* `checkboxLabel` String (opcional) - Si se proporciona, el cuadro de mensaje será incluido como un checkbox con la etiqueta dada.
* `checkboxChecked` Boolean (opcional) - Estado inicial checked del checkbox. `false` por defecto.
* `icon` [NativeImage](native-image.md) (opcional)
+ * `textWidth` Integer (optional) _macOS_ - Custom width of the text in the message box.
* `cancelId` Íntegro (opcional) - El índice el botón a ser usado a cancelar el diálogo, por vía la llave `Esc`. Por defecto, esto es asignado a el primer botón con "cancelar" o "no" como una etiqueta. Si no existen tales botones etiquetados y esta opción no esta configurada, `0` será usada como el valor de retorno.
* `noLink` Boolean (opcional) - En Windows Electron se tratará de averiguar cuál de los `buttons` son botones comunes (como "Cancelar" o "Sí"), y muestra los otros como links de comandos en el diálogo. Esto puede hacer que el diálogo aparezca en el estilo de las aplicaciones modernas de Windows. Si no te gusta este comportamiento, puedes establecer `noLink` a `true`.
* `normalizeAccessKeys` Boolean (opcional) - Normalizar el acceso al teclado a través de las plataformas. Por defecto es `false`. Permitir esto asume que `&` es usado en las etiquetas de los botones para el colocamiento de los atajos de acceso de las teclas del teclado y las etiquetas serán convertidas para que funcionen correctamente en cada plataforma, `&` personajes serán eliminados de macOS, convertidos a `_` en Linux, y dejado intacto en Windows. Por ejemplo, una etiqueta de botón de `Vie&w` será convertida a `Vie_w` en Linux y `View` en macOS y puede ser seleccionado vía `Alt-W` en Windows y Linux.
diff --git a/content/es-ES/docs/api/menu-item.md b/content/es-ES/docs/api/menu-item.md
index ab8f9fde623af..04bf873c60351 100644
--- a/content/es-ES/docs/api/menu-item.md
+++ b/content/es-ES/docs/api/menu-item.md
@@ -132,13 +132,13 @@ Una `String` (opcional) indicando el rol del elemento, si está establecido. Can
#### `menuItem.accelerator`
-An `Accelerator` (optional) indicating the item's accelerator, if set.
+Un `Accelerator` (opcional) indicando el acelerador del elemento, si está establecido.
#### `menuItem.userAccelerator` _Readonly_ _macOS_
-An `Accelerator | null` indicating the item's [user-assigned accelerator](https://developer.apple.com/documentation/appkit/nsmenuitem/1514850-userkeyequivalent?language=objc) for the menu item.
+Un `Accelerator | null` indicando el [user-assigned accelerator](https://developer.apple.com/documentation/appkit/nsmenuitem/1514850-userkeyequivalent?language=objc) del elemento para el menú del elemento.
-**Note:** This property is only initialized after the `MenuItem` has been added to a `Menu`. Either via `Menu.buildFromTemplate` or via `Menu.append()/insert()`. Accessing before initialization will just return `null`.
+**Nota:** Esta propiedad es solo inicializada después de que `MenuItem` a sido agregada al `Menu`. Ya sea a través de `Menu.buildFromTemplate` o a través de `Menu.append()/insert()`. Accediendo antes de la inicialización solo devolverá `null`.
#### `menuItem.icon`
diff --git a/content/es-ES/docs/api/session.md b/content/es-ES/docs/api/session.md
index acfcd65f10305..f058502722fce 100644
--- a/content/es-ES/docs/api/session.md
+++ b/content/es-ES/docs/api/session.md
@@ -160,7 +160,92 @@ Devuelve:
Emitted when a hunspell dictionary file download fails. For details on the failure you should collect a netlog and inspect the download request.
-#### Event: 'select-serial-port'
+#### Event: 'select-hid-device'
+
+Devuelve:
+
+* `event`
+* `details` Object
+ * `deviceList` [HIDDevice[]](structures/hid-device.md)
+ * `frame` [WebFrameMain](web-frame-main.md)
+* `callback` Función
+ * `deviceId` String | null (optional)
+
+Emitted when a HID device needs to be selected when a call to `navigator.hid.requestDevice` is made. `callback` should be called with `deviceId` to be selected; passing no arguments to `callback` will cancel the request. Additionally, permissioning on `navigator.hid` can be further managed by using [ses.setPermissionCheckHandler(handler)](#sessetpermissioncheckhandlerhandler) and [ses.setDevicePermissionHandler(handler)`](#sessetdevicepermissionhandlerhandler).
+
+```javascript
+const { app, BrowserWindow } = require('electron')
+
+let win = null
+
+app.whenReady().then(() => {
+ win = new BrowserWindow()
+
+ win.webContents.session.setPermissionCheckHandler((webContents, permission, requestingOrigin, details) => {
+ if (permission === 'hid') {
+ // Add logic here to determine if permission should be given to allow HID selection
+ return true
+ }
+ return false
+ })
+
+ // Optionally, retrieve previously persisted devices from a persistent store
+ const grantedDevices = fetchGrantedDevices()
+
+ win.webContents.session.setDevicePermissionHandler((details) => {
+ if (new URL(details.origin).hostname === 'some-host' && details.deviceType === 'hid') {
+ if (details.device.vendorId === 123 && details.device.productId === 345) {
+ // Always allow this type of device (this allows skipping the call to `navigator.hid.requestDevice` first)
+ return true
+ }
+
+ // Search through the list of devices that have previously been granted permission
+ return grantedDevices.some((grantedDevice) => {
+ return grantedDevice.vendorId === details.device.vendorId &&
+ grantedDevice.productId === details.device.productId &&
+ grantedDevice.serialNumber && grantedDevice.serialNumber === details.device.serialNumber
+ })
+ }
+ return false
+ })
+
+ win.webContents.session.on('select-hid-device', (event, details, callback) => {
+ event.preventDefault()
+ const selectedDevice = details.deviceList.find((device) => {
+ return device.vendorId === '9025' && device.productId === '67'
+ })
+ callback(selectedPort?.deviceId)
+ })
+})
+```
+
+#### Event: 'hid-device-added'
+
+Devuelve:
+
+* `event`
+* `details` Object
+ * `device` [HIDDevice[]](structures/hid-device.md)
+ * `frame` [WebFrameMain](web-frame-main.md)
+
+Emitted when a new HID device becomes available. For example, when a new USB device is plugged in.
+
+This event will only be emitted after `navigator.hid.requestDevice` has been called and `select-hid-device` has fired.
+
+#### Event: 'hid-device-removed'
+
+Devuelve:
+
+* `event`
+* `details` Object
+ * `device` [HIDDevice[]](structures/hid-device.md)
+ * `frame` [WebFrameMain](web-frame-main.md)
+
+Emitted when a HID device has been removed. For example, this event will fire when a USB device is unplugged.
+
+This event will only be emitted after `navigator.hid.requestDevice` has been called and `select-hid-device` has fired.
+
+#### Evento: 'select-serial-port'
Devuelve:
@@ -196,7 +281,7 @@ app.whenReady().then(() => {
})
```
-#### Event: 'serial-port-added'
+#### Evento: 'serial-port-added'
Devuelve:
@@ -206,7 +291,7 @@ Devuelve:
Emitted after `navigator.serial.requestPort` has been called and `select-serial-port` has fired if a new serial port becomes available. For example, this event will fire when a new USB device is plugged in.
-#### Event: 'serial-port-removed'
+#### Evento: 'serial-port-removed'
Devuelve:
@@ -447,7 +532,7 @@ session.fromPartition('some-partition').setPermissionRequestHandler((webContents
* `handler` Función\ | null
* `webContents` ([WebContents](web-contents.md) | null) - WebContents verificando el permiso. Por favor, tenga en cuenta que si la solicitud viene de un subframe debe utilizar `requestUrl` para comprobar el origen de la solicitud. All cross origin sub frames making permission checks will pass a `null` webContents to this handler, while certain other permission checks such as `notifications` checks will always pass `null`. Debería usar `embeddingOrigin` y `requestingOrigin` para determinar que origen se encuentra en el marco propietario y en el marco solicitante respectivamente.
- * `permission` String - Type of permission check. Valid values are `midiSysex`, `notifications`, `geolocation`, `media`,`mediaKeySystem`,`midi`, `pointerLock`, `fullscreen`, `openExternal`, or `serial`.
+ * `permission` String - Type of permission check. Valid values are `midiSysex`, `notifications`, `geolocation`, `media`,`mediaKeySystem`,`midi`, `pointerLock`, `fullscreen`, `openExternal`, `hid`, or `serial`.
* `requestingOrigin` String - La URL de origen para la comprobación de permisos
* `details` Object - Some properties are only available on certain permission types.
* `embeddingOrigin` String (opcional) - El origen del marco que incrusta el marco que hizo la verificación de permisos. Sólo se establece cross-origin submarcos haciendo comprobaciones de permisos.
@@ -470,6 +555,63 @@ session.fromPartition('some-partition').setPermissionCheckHandler((webContents,
})
```
+#### `ses.setDevicePermissionHandler(handler)`
+
+* `handler` Función\ | null
+ * `details` Object
+ * `deviceType` String - The type of device that permission is being requested on, can be `hid`.
+ * `origin` String - The origin URL of the device permission check.
+ * `device` [HIDDevice](structures/hid-device.md) - the device that permission is being requested for.
+ * `frame` [WebFrameMain](web-frame-main.md) - WebFrameMain checking the device permission.
+
+Sets the handler which can be used to respond to device permission checks for the `session`. Returning `true` will allow the device to be permitted and `false` will reject it. To clear the handler, call `setDevicePermissionHandler(null)`. This handler can be used to provide default permissioning to devices without first calling for permission to devices (eg via `navigator.hid.requestDevice`). If this handler is not defined, the default device permissions as granted through device selection (eg via `navigator.hid.requestDevice`) will be used. Additionally, the default behavior of Electron is to store granted device permision through the lifetime of the corresponding WebContents. If longer term storage is needed, a developer can store granted device permissions (eg when handling the `select-hid-device` event) and then read from that storage with `setDevicePermissionHandler`.
+
+```javascript
+const { app, BrowserWindow } = require('electron')
+
+let win = null
+
+app.whenReady().then(() => {
+ win = new BrowserWindow()
+
+ win.webContents.session.setPermissionCheckHandler((webContents, permission, requestingOrigin, details) => {
+ if (permission === 'hid') {
+ // Add logic here to determine if permission should be given to allow HID selection
+ return true
+ }
+ return false
+ })
+
+ // Optionally, retrieve previously persisted devices from a persistent store
+ const grantedDevices = fetchGrantedDevices()
+
+ win.webContents.session.setDevicePermissionHandler((details) => {
+ if (new URL(details.origin).hostname === 'some-host' && details.deviceType === 'hid') {
+ if (details.device.vendorId === 123 && details.device.productId === 345) {
+ // Always allow this type of device (this allows skipping the call to `navigator.hid.requestDevice` first)
+ return true
+ }
+
+ // Search through the list of devices that have previously been granted permission
+ return grantedDevices.some((grantedDevice) => {
+ return grantedDevice.vendorId === details.device.vendorId &&
+ grantedDevice.productId === details.device.productId &&
+ grantedDevice.serialNumber && grantedDevice.serialNumber === details.device.serialNumber
+ })
+ }
+ return false
+ })
+
+ win.webContents.session.on('select-hid-device', (event, details, callback) => {
+ event.preventDefault()
+ const selectedDevice = details.deviceList.find((device) => {
+ return device.vendorId === '9025' && device.productId === '67'
+ })
+ callback(selectedPort?.deviceId)
+ })
+})
+```
+
#### `ses.clearHostResolverCache()`
Devuelve `Promise` - Se resuelve cuando la operación es completada.
diff --git a/content/es-ES/docs/api/structures/hid-device.md b/content/es-ES/docs/api/structures/hid-device.md
new file mode 100644
index 0000000000000..fac2b6276a9df
--- /dev/null
+++ b/content/es-ES/docs/api/structures/hid-device.md
@@ -0,0 +1,8 @@
+# HIDDevice Object
+
+* `deviceId` String - Unique identifier for the device.
+* `name` String - Name of the device.
+* `vendorId` Integer - The USB vendor ID.
+* `productId` Integer - The USB product ID.
+* `serialNumber` String (optional) - The USB device serial number.
+* `guid` String (optional) - Unique identifier for the HID interface. A device may have multiple HID interfaces.
diff --git a/content/es-ES/docs/api/web-contents.md b/content/es-ES/docs/api/web-contents.md
index 295fc2d219988..598bf3f8ab1d1 100644
--- a/content/es-ES/docs/api/web-contents.md
+++ b/content/es-ES/docs/api/web-contents.md
@@ -122,7 +122,7 @@ Devuelve:
* `event`
-Emitted when the document in the top-level frame is loaded.
+Emitido cuando el documento el el nivel superior está cargado.
#### Evento: 'page-title-updated'
@@ -405,8 +405,8 @@ Devuelve:
* `control` Boolean - Es igual a [KeyboardEvent.controlKey][keyboardevent].
* `alt` Boolean - Es igual a [KeyboardEvent.altKey][keyboardevent].
* `meta` Boolean - Es igual a [KeyboardEvent.metaKey][keyboardevent].
- * `location` Number - Equivalent to [KeyboardEvent.location][keyboardevent].
- * `modifiers` String[] - See [InputEvent.modifiers](structures/input-event.md).
+ * `location` Number - Equivalente a [KeyboardEvent.location][keyboardevent].
+ * `modifiers` String[] - Ver [InputEvent.modifiers](structures/input-event.md).
Emitido antes de enviar los eventos `keydown` y `keyup` en la página. Llamando a `event.preventDefault` evitará la página `keydown`/ eventos `keyup` y los accesos rápidos al menú.
@@ -463,6 +463,7 @@ Devuelve:
* `certificate` [certificate](structures/certificate.md)
* `callback` Función
* `isTrusted` Boolean - Indicates whether the certificate can be considered trusted.
+* `EsElFramePrincipal` Boolean
Emitido cuando no se pudo verificar el `certificate` for `url`.
@@ -570,6 +571,7 @@ Devuelve:
* `params` Object
* `x` Integer - x coordinate.
* `y` Integer - y coordinate.
+ * `frame` WebFrameMain - Frame from which the context menu was invoked.
* `linkURL` String - URL del enlace que incluye el nodo del menú contextual que fue invocado.
* `linkText` String - Text associated with the link. May be an empty string if the contents of the link are an image.
* `pageURL` String - URL de la parte superior del nivel de la página que se invocó en el menú del contexto.
@@ -758,7 +760,7 @@ Emitted when the `WebContents` preferred size has changed.
This event will only be emitted when `enablePreferredSizeMode` is set to `true` in `webPreferences`.
-#### Event: 'frame-created'
+#### Evento: 'frame-created'
Devuelve:
@@ -766,7 +768,7 @@ Devuelve:
* `details` Object
* `frame` WebFrameMain
-Emitted when the [mainFrame](web-contents.md#contentsmainframe-readonly), an `
+Returns `Boolean` - 如果开启了Chrome的辅助功能, 则返回 `true`,其他情况返`false`。 如果使用了辅助技术(例如屏幕阅读),该 API 将返回 `true`。 查看更多细节,请查阅 https://www.chromium.org/developers/design-documents/accessibility
-app.setAccessibilitySupportEnabled(enabled)` _macOS_ _Windows_
+### `app.setAccessibilitySupportEnabled(enabled)` _macOS_ _Windows_
* `enable` 逻辑值 - 启用或禁用[访问权限树](https://developers.google.com/web/fundamentals/accessibility/semantics-builtin/the-accessibility-tree)视图。
diff --git a/content/zh-CN/docs/api/browser-window.md b/content/zh-CN/docs/api/browser-window.md
index 670ce3c48cb61..be820c374983e 100644
--- a/content/zh-CN/docs/api/browser-window.md
+++ b/content/zh-CN/docs/api/browser-window.md
@@ -757,7 +757,7 @@ Menu.setApplicationMenu(menu)
想象一个使用高清视频播放器和相关控件的普通窗口。 假假如左边缘有15px, 右边缘有25px, 在播放器下面有50px. 为了保持播放器本身16:9 的长宽比 (标准的HD长宽比为1920x1080), 我们可以使用 16/9 和 { width: 40, height: 50 } 的参数调用这个函数。 第二个参数不管网页中的额外的宽度和高度在什么位置, 只要它们存在就行. 在全部内部窗口中,加上任何额外的宽度和高度 。
-当窗口使用类似于 `win.setSize` 这样的 API 调整窗口时,宽高比不会被采用。
+The aspect ratio is not respected when window is resized programmatically with APIs like `win.setSize`.
#### `win.setBackgroundColor(backgroundColor)`
diff --git a/content/zh-CN/docs/api/dialog.md b/content/zh-CN/docs/api/dialog.md
index 67f834e210af8..225f7771e4986 100644
--- a/content/zh-CN/docs/api/dialog.md
+++ b/content/zh-CN/docs/api/dialog.md
@@ -187,6 +187,7 @@ dialog.showOpenDialog(mainWindow, {
* `title` String (可选) - message box 的标题,一些平台不显示.
* `detail` String (可选) - 额外信息.
* `icon` ([NativeImage](native-image.md) | String) (可选)
+ * `textWidth` Integer (optional) _macOS_ - Custom width of the text in the message box.
* `cancelId` Integer (可选) - 用于取消对话框的按钮的索引,例如 `Esc` 键. 默认情况下,它被分配给第一个按钮,文字为 “cancel” 或 “no”。 如果不存在这个标签的按钮,同时该选项又未设置,返回值为`0`。
* `noLink` Boolean (可选) - 在Windows上,应用将尝试找出哪个 `buttons` 是常用按钮(例如 "Cancel" 或 "Yes"),然后在对话框中以链接命令的方式展现其它的按钮。 这可以使对话框以现代Windows应用程序的风格显示。 如果你不喜欢这个行为, 你可以设置 `noLink` 为 `true`.
* `normalizeAccessKeys` Boolean (可选) -规范跨平台的键盘访问键。 默认值为 `false`. 用 `&` 连接和转换键盘访问键, 以便它们在每个平台上正常工作.`&` 字符会在macOS上被删除,在 Linux 上会被转换为 `_`,在 Windows 上保持不变。 例如 `Vie&w` 的按钮标签在 Linux 上会被转换为 `Vie_w`,在 macOS 转换为 `View` 并且可以被选择。而Windows和Linux上表示 `Alt-W` 。
@@ -211,6 +212,7 @@ dialog.showOpenDialog(mainWindow, {
* `checkboxLabel` String (可选) - 如果使用了,消息框将包含带有给定标签的复选框。
* `checkboxChecked` Boolean (可选) - checkbox 的初始值。 默认值为 `false`
* `icon` [NativeImage](native-image.md) (可选)
+ * `textWidth` Integer (optional) _macOS_ - Custom width of the text in the message box.
* `cancelId` Integer (可选) - 用于取消对话框的按钮的索引,例如 `Esc` 键. 默认情况下,它被分配给第一个按钮,文字为 “cancel” 或 “no”。 如果不存在这个标签的按钮,同时该选项又未设置,返回值为`0`。
* `noLink` Boolean (可选) - 在Windows上,应用将尝试找出哪个 `buttons` 是常用按钮(例如 "Cancel" 或 "Yes"),然后在对话框中以链接命令的方式展现其它的按钮。 这可以使对话框以现代Windows应用程序的风格显示。 如果你不喜欢这个行为, 你可以设置 `noLink` 为 `true`.
* `normalizeAccessKeys` Boolean (可选) -规范跨平台的键盘访问键。 默认值为 `false`. 用 `&` 连接和转换键盘访问键, 以便它们在每个平台上正常工作.`&` 字符会在macOS上被删除,在 Linux 上会被转换为 `_`,在 Windows 上保持不变。 例如 `Vie&w` 的按钮标签在 Linux 上会被转换为 `Vie_w`,在 macOS 转换为 `View` 并且可以被选择。而Windows和Linux上表示 `Alt-W` 。
diff --git a/content/zh-CN/docs/api/session.md b/content/zh-CN/docs/api/session.md
index e68d0fbcf1557..0eb0c5f22d503 100644
--- a/content/zh-CN/docs/api/session.md
+++ b/content/zh-CN/docs/api/session.md
@@ -160,6 +160,91 @@ session.defaultSession.on('will-download', (event, item, webContents) => {
当hunspell字典下载失败时触发。 如果需要详细信息,你应当查看网络日志并且检查下载请求。
+#### Event: 'select-hid-device'
+
+返回:
+
+* `event` Event
+* `details` Object
+ * `deviceList` [HIDDevice[]](structures/hid-device.md)
+ * `frame` [WebFrameMain](web-frame-main.md)
+* `callback` Function
+ * `deviceId` String | null (optional)
+
+Emitted when a HID device needs to be selected when a call to `navigator.hid.requestDevice` is made. `callback` should be called with `deviceId` to be selected; passing no arguments to `callback` will cancel the request. Additionally, permissioning on `navigator.hid` can be further managed by using [ses.setPermissionCheckHandler(handler)](#sessetpermissioncheckhandlerhandler) and [ses.setDevicePermissionHandler(handler)`](#sessetdevicepermissionhandlerhandler).
+
+```javascript
+const { app, BrowserWindow } = require('electron')
+
+let win = null
+
+app.whenReady().then(() => {
+ win = new BrowserWindow()
+
+ win.webContents.session.setPermissionCheckHandler((webContents, permission, requestingOrigin, details) => {
+ if (permission === 'hid') {
+ // Add logic here to determine if permission should be given to allow HID selection
+ return true
+ }
+ return false
+ })
+
+ // Optionally, retrieve previously persisted devices from a persistent store
+ const grantedDevices = fetchGrantedDevices()
+
+ win.webContents.session.setDevicePermissionHandler((details) => {
+ if (new URL(details.origin).hostname === 'some-host' && details.deviceType === 'hid') {
+ if (details.device.vendorId === 123 && details.device.productId === 345) {
+ // Always allow this type of device (this allows skipping the call to `navigator.hid.requestDevice` first)
+ return true
+ }
+
+ // Search through the list of devices that have previously been granted permission
+ return grantedDevices.some((grantedDevice) => {
+ return grantedDevice.vendorId === details.device.vendorId &&
+ grantedDevice.productId === details.device.productId &&
+ grantedDevice.serialNumber && grantedDevice.serialNumber === details.device.serialNumber
+ })
+ }
+ return false
+ })
+
+ win.webContents.session.on('select-hid-device', (event, details, callback) => {
+ event.preventDefault()
+ const selectedDevice = details.deviceList.find((device) => {
+ return device.vendorId === '9025' && device.productId === '67'
+ })
+ callback(selectedPort?.deviceId)
+ })
+})
+```
+
+#### Event: 'hid-device-added'
+
+返回:
+
+* `event` Event
+* `details` Object
+ * `device` [HIDDevice[]](structures/hid-device.md)
+ * `frame` [WebFrameMain](web-frame-main.md)
+
+Emitted when a new HID device becomes available. For example, when a new USB device is plugged in.
+
+This event will only be emitted after `navigator.hid.requestDevice` has been called and `select-hid-device` has fired.
+
+#### Event: 'hid-device-removed'
+
+返回:
+
+* `event` Event
+* `details` Object
+ * `device` [HIDDevice[]](structures/hid-device.md)
+ * `frame` [WebFrameMain](web-frame-main.md)
+
+Emitted when a HID device has been removed. 比如, 当一个USB设备被移除时。
+
+This event will only be emitted after `navigator.hid.requestDevice` has been called and `select-hid-device` has fired.
+
#### Event: 'select-serial-port'
返回:
@@ -447,7 +532,7 @@ session.fromPartition('some-partition').setPermissionRequestHandler((webContents
* `handler` 函数\ | null
* `webContents` ([WebContents](web-contents.md) | null) - WebContents checking the permission. Please note that if the request comes from a subframe you should use `requestingUrl` to check the request origin. 所有进行权限检查的跨源子帧将传递一个 `null` 的 webContents 对象给此处理程序,而某些其他权限检查(如 `notifications` 检查)将始终传递一个 `null`。 You should use `embeddingOrigin` and `requestingOrigin` to determine what origin the owning frame and the requesting frame are on respectively.
- * `permission` String - Type of permission check. Valid values are `midiSysex`, `notifications`, `geolocation`, `media`,`mediaKeySystem`,`midi`, `pointerLock`, `fullscreen`, `openExternal`, or `serial`.
+ * `permission` String - Type of permission check. Valid values are `midiSysex`, `notifications`, `geolocation`, `media`,`mediaKeySystem`,`midi`, `pointerLock`, `fullscreen`, `openExternal`, `hid`, or `serial`.
* `requestingOrigin` String - The origin URL of the permission check
* `details` Object - Some properties are only available on certain permission types.
* `embeddingOrigin` String (optional) - The origin of the frame embedding the frame that made the permission check. Only set for cross-origin sub frames making permission checks.
@@ -470,6 +555,63 @@ session.fromPartition('some-partition').setPermissionCheckHandler((webContents,
})
```
+#### `ses.setDevicePermissionHandler(handler)`
+
+* `handler` 函数\ | null
+ * `details` Object
+ * `deviceType` String - The type of device that permission is being requested on, can be `hid`.
+ * `origin` String - The origin URL of the device permission check.
+ * `device` [HIDDevice](structures/hid-device.md) - the device that permission is being requested for.
+ * `frame` [WebFrameMain](web-frame-main.md) - WebFrameMain checking the device permission.
+
+Sets the handler which can be used to respond to device permission checks for the `session`. Returning `true` will allow the device to be permitted and `false` will reject it. To clear the handler, call `setDevicePermissionHandler(null)`. This handler can be used to provide default permissioning to devices without first calling for permission to devices (eg via `navigator.hid.requestDevice`). If this handler is not defined, the default device permissions as granted through device selection (eg via `navigator.hid.requestDevice`) will be used. Additionally, the default behavior of Electron is to store granted device permision through the lifetime of the corresponding WebContents. If longer term storage is needed, a developer can store granted device permissions (eg when handling the `select-hid-device` event) and then read from that storage with `setDevicePermissionHandler`.
+
+```javascript
+const { app, BrowserWindow } = require('electron')
+
+let win = null
+
+app.whenReady().then(() => {
+ win = new BrowserWindow()
+
+ win.webContents.session.setPermissionCheckHandler((webContents, permission, requestingOrigin, details) => {
+ if (permission === 'hid') {
+ // Add logic here to determine if permission should be given to allow HID selection
+ return true
+ }
+ return false
+ })
+
+ // Optionally, retrieve previously persisted devices from a persistent store
+ const grantedDevices = fetchGrantedDevices()
+
+ win.webContents.session.setDevicePermissionHandler((details) => {
+ if (new URL(details.origin).hostname === 'some-host' && details.deviceType === 'hid') {
+ if (details.device.vendorId === 123 && details.device.productId === 345) {
+ // Always allow this type of device (this allows skipping the call to `navigator.hid.requestDevice` first)
+ return true
+ }
+
+ // Search through the list of devices that have previously been granted permission
+ return grantedDevices.some((grantedDevice) => {
+ return grantedDevice.vendorId === details.device.vendorId &&
+ grantedDevice.productId === details.device.productId &&
+ grantedDevice.serialNumber && grantedDevice.serialNumber === details.device.serialNumber
+ })
+ }
+ return false
+ })
+
+ win.webContents.session.on('select-hid-device', (event, details, callback) => {
+ event.preventDefault()
+ const selectedDevice = details.deviceList.find((device) => {
+ return device.vendorId === '9025' && device.productId === '67'
+ })
+ callback(selectedPort?.deviceId)
+ })
+})
+```
+
#### `ses.clearHostResolverCache()`
Returns `Promise` - Resolves when the operation is complete.
diff --git a/content/zh-CN/docs/api/structures/hid-device.md b/content/zh-CN/docs/api/structures/hid-device.md
new file mode 100644
index 0000000000000..fac2b6276a9df
--- /dev/null
+++ b/content/zh-CN/docs/api/structures/hid-device.md
@@ -0,0 +1,8 @@
+# HIDDevice Object
+
+* `deviceId` String - Unique identifier for the device.
+* `name` String - Name of the device.
+* `vendorId` Integer - The USB vendor ID.
+* `productId` Integer - The USB product ID.
+* `serialNumber` String (optional) - The USB device serial number.
+* `guid` String (optional) - Unique identifier for the HID interface. A device may have multiple HID interfaces.
diff --git a/content/zh-CN/docs/api/web-contents.md b/content/zh-CN/docs/api/web-contents.md
index d4fec4a3c242e..061f2a8d54509 100644
--- a/content/zh-CN/docs/api/web-contents.md
+++ b/content/zh-CN/docs/api/web-contents.md
@@ -463,6 +463,7 @@ Emitted when the user is requesting to change the zoom level using the mouse whe
* `certificate` [证书](structures/certificate.md)
* `callback` Function
* `isTrusted` Boolean - 用于显示证书是否可信。
+* `isMainFrame` Boolean
`证书`的`链接`验证失败时,触发该事件。
@@ -570,6 +571,7 @@ If the `type` parameter is `custom`, the `image` parameter will hold the custom
* `params` Object
* `x` Integer - x 坐标。
* `y` Integer - y 坐标。
+ * `frame` WebFrameMain - Frame from which the context menu was invoked.
* `linkURL` String - URL of the link that encloses the node the context menu was invoked on.
* `linkText` String - Text associated with the link. May be an empty string if the contents of the link are an image.
* `pageURL` String - URL of the top level page that the context menu was invoked on.
@@ -1477,7 +1479,7 @@ Opens the developer tools for the service worker context.
* `channel` String
* `...args` any[]
-Send an asynchronous message to the renderer process via `channel`, along with arguments. Arguments will be serialized with the [Structured Clone Algorithm][SCA], just like [`postMessage`][], so prototype chains will not be included. 发送 Functions, Promises, Symbols, WeakMaps, 或 WeakSets 将抛出异常
+Send an asynchronous message to the renderer process via `channel`, along with arguments. 参数将使用 [Structured Clone Algorithm][SCA]进行序列化,就像 [`postMessage`][],因此原型链将不会包含在内。 发送 Functions, Promises, Symbols, WeakMaps, 或 WeakSets 将抛出异常
> **NOTE**: Sending non-standard JavaScript types such as DOM objects or special Electron objects will throw an exception.
@@ -1608,7 +1610,8 @@ End subscribing for frame presentation events.
#### `contents.startDrag(item)`
* `item` Object
- * `file` String[] | String - The path(s) to the file(s) being dragged.
+ * `file` String - The path to the file being dragged.
+ * `files` String[] (optional) - The paths to the files being dragged. (`files` will override `file` field)
* `icon` [NativeImage](native-image.md) | String - The image must be non-empty on macOS.
Sets the `item` as dragging item for current drag-drop operation, `file` is the absolute path of the file to be dragged, and `icon` is the image showing under the cursor when dragging.