📝 Add missing semicolons
[ci skip]
This commit is contained in:
parent
6e0112bf9f
commit
139a4f984a
12 changed files with 32 additions and 32 deletions
|
@ -210,7 +210,7 @@ certificate from the store.
|
||||||
app.on('select-client-certificate', function(event, webContents, url, list, callback) {
|
app.on('select-client-certificate', function(event, webContents, url, list, callback) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
callback(list[0]);
|
callback(list[0]);
|
||||||
})
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
### Event: 'login'
|
### Event: 'login'
|
||||||
|
@ -241,7 +241,7 @@ should prevent the default behavior with `event.preventDefault()` and call
|
||||||
app.on('login', (event, webContents, request, authInfo, callback) => {
|
app.on('login', (event, webContents, request, authInfo, callback) => {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
callback('username', 'secret');
|
callback('username', 'secret');
|
||||||
})
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
### Event: 'gpu-process-crashed'
|
### Event: 'gpu-process-crashed'
|
||||||
|
|
|
@ -13,7 +13,7 @@ const {contentTracing} = require('electron');
|
||||||
const options = {
|
const options = {
|
||||||
categoryFilter: '*',
|
categoryFilter: '*',
|
||||||
traceOptions: 'record-until-full,enable-sampling'
|
traceOptions: 'record-until-full,enable-sampling'
|
||||||
}
|
};
|
||||||
|
|
||||||
contentTracing.startRecording(options, function() {
|
contentTracing.startRecording(options, function() {
|
||||||
console.log('Tracing started');
|
console.log('Tracing started');
|
||||||
|
|
|
@ -6,18 +6,18 @@ An example of implementing a protocol that has the same effect as the
|
||||||
`file://` protocol:
|
`file://` protocol:
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
const {app, protocol} = require('electron')
|
const {app, protocol} = require('electron');
|
||||||
const path = require('path')
|
const path = require('path');
|
||||||
|
|
||||||
app.on('ready', function () {
|
app.on('ready', function () {
|
||||||
protocol.registerFileProtocol('atom', function (request, callback) {
|
protocol.registerFileProtocol('atom', function (request, callback) {
|
||||||
const url = request.url.substr(7)
|
const url = request.url.substr(7);
|
||||||
callback({path: path.normalize(__dirname + '/' + url)})
|
callback({path: path.normalize(__dirname + '/' + url)});
|
||||||
}, function (error) {
|
}, function (error) {
|
||||||
if (error)
|
if (error)
|
||||||
console.error('Failed to register protocol')
|
console.error('Failed to register protocol');
|
||||||
})
|
});
|
||||||
})
|
});
|
||||||
```
|
```
|
||||||
**Note:** All methods unless specified can only be used after the `ready` event
|
**Note:** All methods unless specified can only be used after the `ready` event
|
||||||
of the `app` module gets emitted.
|
of the `app` module gets emitted.
|
||||||
|
@ -52,10 +52,10 @@ So if you want to register a custom protocol to replace the `http` protocol, you
|
||||||
have to register it as standard scheme:
|
have to register it as standard scheme:
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
protocol.registerStandardSchemes(['atom'])
|
protocol.registerStandardSchemes(['atom']);
|
||||||
app.on('ready', function () {
|
app.on('ready', function () {
|
||||||
protocol.registerHttpProtocol('atom', ...)
|
protocol.registerHttpProtocol('atom', ...);
|
||||||
})
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
**Note:** This method can only be used before the `ready` event of the `app`
|
**Note:** This method can only be used before the `ready` event of the `app`
|
||||||
|
@ -123,7 +123,7 @@ protocol.registerBufferProtocol('atom', (request, callback) => {
|
||||||
callback({mimeType: 'text/html', data: new Buffer('<h5>Response</h5>')});
|
callback({mimeType: 'text/html', data: new Buffer('<h5>Response</h5>')});
|
||||||
}, (error) => {
|
}, (error) => {
|
||||||
if (error)
|
if (error)
|
||||||
console.error('Failed to register protocol')
|
console.error('Failed to register protocol');
|
||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
@ -70,11 +70,11 @@ For instance you can't use a function from the renderer process in an
|
||||||
// main process mapNumbers.js
|
// main process mapNumbers.js
|
||||||
exports.withRendererCallback = (mapper) => {
|
exports.withRendererCallback = (mapper) => {
|
||||||
return [1,2,3].map(mapper);
|
return [1,2,3].map(mapper);
|
||||||
}
|
};
|
||||||
|
|
||||||
exports.withLocalCallback = () => {
|
exports.withLocalCallback = () => {
|
||||||
return exports.mapNumbers(x => x + 1);
|
return exports.mapNumbers(x => x + 1);
|
||||||
}
|
};
|
||||||
```
|
```
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
|
@ -83,9 +83,9 @@ const mapNumbers = require('remote').require('./mapNumbers');
|
||||||
|
|
||||||
const withRendererCb = mapNumbers.withRendererCallback(x => x + 1);
|
const withRendererCb = mapNumbers.withRendererCallback(x => x + 1);
|
||||||
|
|
||||||
const withLocalCb = mapNumbers.withLocalCallback()
|
const withLocalCb = mapNumbers.withLocalCallback();
|
||||||
|
|
||||||
console.log(withRendererCb, withLocalCb) // [true, true, true], [2, 3, 4]
|
console.log(withRendererCb, withLocalCb); // [true, true, true], [2, 3, 4]
|
||||||
```
|
```
|
||||||
|
|
||||||
As you can see, the renderer callback's synchronous return value was not as
|
As you can see, the renderer callback's synchronous return value was not as
|
||||||
|
|
|
@ -88,7 +88,7 @@ process.env.ELECTRON_HIDE_INTERNAL_MODULES = 'true'
|
||||||
Or call the `hideInternalModules` API:
|
Or call the `hideInternalModules` API:
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
require('electron').hideInternalModules()
|
require('electron').hideInternalModules();
|
||||||
```
|
```
|
||||||
|
|
||||||
[gui]: https://en.wikipedia.org/wiki/Graphical_user_interface
|
[gui]: https://en.wikipedia.org/wiki/Graphical_user_interface
|
||||||
|
|
|
@ -385,7 +385,7 @@ use the `pragma` header to achieve it.
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
const options = {extraHeaders: 'pragma: no-cache\n'};
|
const options = {extraHeaders: 'pragma: no-cache\n'};
|
||||||
webContents.loadURL(url, options)
|
webContents.loadURL(url, options);
|
||||||
```
|
```
|
||||||
|
|
||||||
### `webContents.downloadURL(url)`
|
### `webContents.downloadURL(url)`
|
||||||
|
@ -942,7 +942,7 @@ win.webContents.debugger.on('message', (event, method, params) => {
|
||||||
if (params.request.url === 'https://www.github.com')
|
if (params.request.url === 'https://www.github.com')
|
||||||
win.webContents.debugger.detach();
|
win.webContents.debugger.detach();
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
|
|
||||||
win.webContents.debugger.sendCommand('Network.enable');
|
win.webContents.debugger.sendCommand('Network.enable');
|
||||||
```
|
```
|
||||||
|
|
|
@ -37,15 +37,15 @@ and displays a "loading..." message during the load time:
|
||||||
|
|
||||||
const loadstart = () => {
|
const loadstart = () => {
|
||||||
indicator.innerText = 'loading...';
|
indicator.innerText = 'loading...';
|
||||||
}
|
};
|
||||||
|
|
||||||
const loadstop = () => {
|
const loadstop = () => {
|
||||||
indicator.innerText = '';
|
indicator.innerText = '';
|
||||||
}
|
};
|
||||||
|
|
||||||
webview.addEventListener('did-start-loading', loadstart);
|
webview.addEventListener('did-start-loading', loadstart);
|
||||||
webview.addEventListener('did-stop-loading', loadstop);
|
webview.addEventListener('did-stop-loading', loadstop);
|
||||||
}
|
};
|
||||||
</script>
|
</script>
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
@ -65,7 +65,7 @@ code from this:
|
||||||
```javascript
|
```javascript
|
||||||
app.on('ready', () => {
|
app.on('ready', () => {
|
||||||
const tray = new Tray('/path/to/icon.png');
|
const tray = new Tray('/path/to/icon.png');
|
||||||
})
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
to this:
|
to this:
|
||||||
|
@ -74,7 +74,7 @@ to this:
|
||||||
let tray = null;
|
let tray = null;
|
||||||
app.on('ready', () => {
|
app.on('ready', () => {
|
||||||
tray = new Tray('/path/to/icon.png');
|
tray = new Tray('/path/to/icon.png');
|
||||||
})
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
## I can not use jQuery/RequireJS/Meteor/AngularJS in Electron.
|
## I can not use jQuery/RequireJS/Meteor/AngularJS in Electron.
|
||||||
|
|
|
@ -93,6 +93,6 @@ this event it might look something like this:
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
Alarm.on('wake-up', (time) => {
|
Alarm.on('wake-up', (time) => {
|
||||||
console.log(time)
|
console.log(time);
|
||||||
})
|
});
|
||||||
```
|
```
|
||||||
|
|
|
@ -23,8 +23,8 @@ let myNotification = new Notification('Title', {
|
||||||
});
|
});
|
||||||
|
|
||||||
myNotification.onclick = function () {
|
myNotification.onclick = function () {
|
||||||
console.log('Notification clicked')
|
console.log('Notification clicked');
|
||||||
}
|
};
|
||||||
```
|
```
|
||||||
|
|
||||||
While code and user experience across operating systems are similar, there
|
While code and user experience across operating systems are similar, there
|
||||||
|
|
|
@ -80,7 +80,7 @@ The `main.js` should create windows and handle system events, a typical
|
||||||
example being:
|
example being:
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
const electron = require('electron')
|
const electron = require('electron');
|
||||||
// Module to control application life.
|
// Module to control application life.
|
||||||
const app = electron.app;
|
const app = electron.app;
|
||||||
// Module to create native browser window.
|
// Module to create native browser window.
|
||||||
|
|
|
@ -66,7 +66,7 @@ app.on('ready', () => {
|
||||||
// The `plugins` have to be enabled.
|
// The `plugins` have to be enabled.
|
||||||
plugins: true
|
plugins: true
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue