📝 Match destructuring style
[ci skip]
This commit is contained in:
parent
5787bb0226
commit
4d7296e1db
24 changed files with 37 additions and 39 deletions
|
@ -7,6 +7,7 @@ closed:
|
|||
|
||||
```javascript
|
||||
const {app} = require('electron');
|
||||
|
||||
app.on('window-all-closed', () => {
|
||||
app.quit();
|
||||
});
|
||||
|
|
|
@ -5,7 +5,7 @@ microphone, camera, or screen.
|
|||
|
||||
```javascript
|
||||
// In the renderer process.
|
||||
var { desktopCapturer } = require('electron');
|
||||
const {desktopCapturer} = require('electron');
|
||||
|
||||
desktopCapturer.getSources({types: ['window', 'screen']}, (error, sources) => {
|
||||
if (error) throw error;
|
||||
|
|
|
@ -7,6 +7,7 @@ An example of showing a dialog to select multiple files and directories:
|
|||
```javascript
|
||||
var win = ...; // BrowserWindow in which to show the dialog
|
||||
const {dialog} = require('electron');
|
||||
|
||||
console.log(dialog.showOpenDialog({ properties: [ 'openFile', 'openDirectory', 'multiSelections' ]}));
|
||||
```
|
||||
|
||||
|
|
|
@ -11,8 +11,7 @@ not have the keyboard focus. You should not use this module until the `ready`
|
|||
event of the app module is emitted.
|
||||
|
||||
```javascript
|
||||
const electron = require('electron');
|
||||
const { app, globalShortcut } = electron;
|
||||
const {app, globalShortcut} = require('electron');
|
||||
|
||||
app.on('ready', () => {
|
||||
// Register a 'CommandOrControl+X' shortcut listener.
|
||||
|
|
|
@ -13,13 +13,12 @@ In our examples below, we use `electronScreen` as the variable name instead.
|
|||
An example of creating a window that fills the whole screen:
|
||||
|
||||
```javascript
|
||||
const electron = require('electron');
|
||||
const { app, BrowserWindow } = electron;
|
||||
const {app, BrowserWindow, screen: electronScreen} = require('electron');
|
||||
|
||||
let mainWindow;
|
||||
|
||||
app.on('ready', () => {
|
||||
const { width, height } = electron.screen.getPrimaryDisplay().workAreaSize;
|
||||
const {width, height} = electronScreen.getPrimaryDisplay().workAreaSize;
|
||||
mainWindow = new BrowserWindow({ width, height });
|
||||
});
|
||||
```
|
||||
|
@ -27,13 +26,11 @@ app.on('ready', () => {
|
|||
Another example of creating a window in the external display:
|
||||
|
||||
```javascript
|
||||
const electron = require('electron');
|
||||
const { app, BrowserWindow } = electron;
|
||||
const {app, BrowserWindow, screen: electronScreen} = require('electron');
|
||||
|
||||
let mainWindow;
|
||||
|
||||
app.on('ready', () => {
|
||||
var electronScreen = electron.screen;
|
||||
var displays = electronScreen.getAllDisplays();
|
||||
var externalDisplay = null;
|
||||
for (let i in displays) {
|
||||
|
|
|
@ -37,8 +37,8 @@ extra ability to use node modules:
|
|||
<html>
|
||||
<body>
|
||||
<script>
|
||||
const { remote } = require('electron');
|
||||
console.log(remote.app.getVersion());
|
||||
const {app} = require('electron').remote;
|
||||
console.log(app.getVersion());
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -732,7 +732,7 @@ webview.send('ping');
|
|||
|
||||
```javascript
|
||||
// In guest page.
|
||||
var { ipcRenderer } = require('electron');
|
||||
const {ipcRenderer} = require('electron');
|
||||
ipcRenderer.on('ping', () => {
|
||||
ipcRenderer.sendToHost('pong');
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue