📝 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) {
|
||||
event.preventDefault();
|
||||
callback(list[0]);
|
||||
})
|
||||
});
|
||||
```
|
||||
|
||||
### Event: 'login'
|
||||
|
@ -241,7 +241,7 @@ should prevent the default behavior with `event.preventDefault()` and call
|
|||
app.on('login', (event, webContents, request, authInfo, callback) => {
|
||||
event.preventDefault();
|
||||
callback('username', 'secret');
|
||||
})
|
||||
});
|
||||
```
|
||||
|
||||
### Event: 'gpu-process-crashed'
|
||||
|
|
|
@ -13,7 +13,7 @@ const {contentTracing} = require('electron');
|
|||
const options = {
|
||||
categoryFilter: '*',
|
||||
traceOptions: 'record-until-full,enable-sampling'
|
||||
}
|
||||
};
|
||||
|
||||
contentTracing.startRecording(options, function() {
|
||||
console.log('Tracing started');
|
||||
|
|
|
@ -6,18 +6,18 @@ An example of implementing a protocol that has the same effect as the
|
|||
`file://` protocol:
|
||||
|
||||
```javascript
|
||||
const {app, protocol} = require('electron')
|
||||
const path = require('path')
|
||||
const {app, protocol} = require('electron');
|
||||
const path = require('path');
|
||||
|
||||
app.on('ready', function () {
|
||||
protocol.registerFileProtocol('atom', function (request, callback) {
|
||||
const url = request.url.substr(7)
|
||||
callback({path: path.normalize(__dirname + '/' + url)})
|
||||
const url = request.url.substr(7);
|
||||
callback({path: path.normalize(__dirname + '/' + url)});
|
||||
}, function (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
|
||||
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:
|
||||
|
||||
```javascript
|
||||
protocol.registerStandardSchemes(['atom'])
|
||||
protocol.registerStandardSchemes(['atom']);
|
||||
app.on('ready', function () {
|
||||
protocol.registerHttpProtocol('atom', ...)
|
||||
})
|
||||
protocol.registerHttpProtocol('atom', ...);
|
||||
});
|
||||
```
|
||||
|
||||
**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>')});
|
||||
}, (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
|
||||
exports.withRendererCallback = (mapper) => {
|
||||
return [1,2,3].map(mapper);
|
||||
}
|
||||
};
|
||||
|
||||
exports.withLocalCallback = () => {
|
||||
return exports.mapNumbers(x => x + 1);
|
||||
}
|
||||
};
|
||||
```
|
||||
|
||||
```javascript
|
||||
|
@ -83,9 +83,9 @@ const mapNumbers = require('remote').require('./mapNumbers');
|
|||
|
||||
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
|
||||
|
|
|
@ -88,7 +88,7 @@ process.env.ELECTRON_HIDE_INTERNAL_MODULES = 'true'
|
|||
Or call the `hideInternalModules` API:
|
||||
|
||||
```javascript
|
||||
require('electron').hideInternalModules()
|
||||
require('electron').hideInternalModules();
|
||||
```
|
||||
|
||||
[gui]: https://en.wikipedia.org/wiki/Graphical_user_interface
|
||||
|
|
|
@ -385,7 +385,7 @@ use the `pragma` header to achieve it.
|
|||
|
||||
```javascript
|
||||
const options = {extraHeaders: 'pragma: no-cache\n'};
|
||||
webContents.loadURL(url, options)
|
||||
webContents.loadURL(url, options);
|
||||
```
|
||||
|
||||
### `webContents.downloadURL(url)`
|
||||
|
@ -942,7 +942,7 @@ win.webContents.debugger.on('message', (event, method, params) => {
|
|||
if (params.request.url === 'https://www.github.com')
|
||||
win.webContents.debugger.detach();
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
win.webContents.debugger.sendCommand('Network.enable');
|
||||
```
|
||||
|
|
|
@ -37,15 +37,15 @@ and displays a "loading..." message during the load time:
|
|||
|
||||
const loadstart = () => {
|
||||
indicator.innerText = 'loading...';
|
||||
}
|
||||
};
|
||||
|
||||
const loadstop = () => {
|
||||
indicator.innerText = '';
|
||||
}
|
||||
};
|
||||
|
||||
webview.addEventListener('did-start-loading', loadstart);
|
||||
webview.addEventListener('did-stop-loading', loadstop);
|
||||
}
|
||||
};
|
||||
</script>
|
||||
```
|
||||
|
||||
|
|
|
@ -65,7 +65,7 @@ code from this:
|
|||
```javascript
|
||||
app.on('ready', () => {
|
||||
const tray = new Tray('/path/to/icon.png');
|
||||
})
|
||||
});
|
||||
```
|
||||
|
||||
to this:
|
||||
|
@ -74,7 +74,7 @@ to this:
|
|||
let tray = null;
|
||||
app.on('ready', () => {
|
||||
tray = new Tray('/path/to/icon.png');
|
||||
})
|
||||
});
|
||||
```
|
||||
|
||||
## I can not use jQuery/RequireJS/Meteor/AngularJS in Electron.
|
||||
|
|
|
@ -93,6 +93,6 @@ this event it might look something like this:
|
|||
|
||||
```javascript
|
||||
Alarm.on('wake-up', (time) => {
|
||||
console.log(time)
|
||||
})
|
||||
console.log(time);
|
||||
});
|
||||
```
|
||||
|
|
|
@ -23,8 +23,8 @@ let myNotification = new Notification('Title', {
|
|||
});
|
||||
|
||||
myNotification.onclick = function () {
|
||||
console.log('Notification clicked')
|
||||
}
|
||||
console.log('Notification clicked');
|
||||
};
|
||||
```
|
||||
|
||||
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:
|
||||
|
||||
```javascript
|
||||
const electron = require('electron')
|
||||
const electron = require('electron');
|
||||
// Module to control application life.
|
||||
const app = electron.app;
|
||||
// Module to create native browser window.
|
||||
|
|
|
@ -66,7 +66,7 @@ app.on('ready', () => {
|
|||
// The `plugins` have to be enabled.
|
||||
plugins: true
|
||||
}
|
||||
})
|
||||
});
|
||||
});
|
||||
```
|
||||
|
||||
|
|
Loading…
Reference in a new issue