📝 Match variable names
[ci skip]
This commit is contained in:
parent
885aeec442
commit
5146befa46
6 changed files with 23 additions and 23 deletions
|
@ -15,11 +15,11 @@ An example of creating a window that fills the whole screen:
|
||||||
```javascript
|
```javascript
|
||||||
const {app, BrowserWindow, screen: electronScreen} = require('electron');
|
const {app, BrowserWindow, screen: electronScreen} = require('electron');
|
||||||
|
|
||||||
let mainWindow;
|
let win;
|
||||||
|
|
||||||
app.on('ready', () => {
|
app.on('ready', () => {
|
||||||
const {width, height} = electronScreen.getPrimaryDisplay().workAreaSize;
|
const {width, height} = electronScreen.getPrimaryDisplay().workAreaSize;
|
||||||
mainWindow = new BrowserWindow({width, height});
|
win = new BrowserWindow({width, height});
|
||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ Another example of creating a window in the external display:
|
||||||
```javascript
|
```javascript
|
||||||
const {app, BrowserWindow, screen: electronScreen} = require('electron');
|
const {app, BrowserWindow, screen: electronScreen} = require('electron');
|
||||||
|
|
||||||
let mainWindow;
|
let win;
|
||||||
|
|
||||||
app.on('ready', () => {
|
app.on('ready', () => {
|
||||||
let displays = electronScreen.getAllDisplays();
|
let displays = electronScreen.getAllDisplays();
|
||||||
|
@ -41,7 +41,7 @@ app.on('ready', () => {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (externalDisplay) {
|
if (externalDisplay) {
|
||||||
mainWindow = new BrowserWindow({
|
win = new BrowserWindow({
|
||||||
x: externalDisplay.bounds.x + 50,
|
x: externalDisplay.bounds.x + 50,
|
||||||
y: externalDisplay.bounds.y + 50
|
y: externalDisplay.bounds.y + 50
|
||||||
});
|
});
|
||||||
|
|
|
@ -700,8 +700,8 @@ Adds the specified path to DevTools workspace. Must be used after DevTools
|
||||||
creation:
|
creation:
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
mainWindow.webContents.on('devtools-opened', () => {
|
win.webContents.on('devtools-opened', () => {
|
||||||
mainWindow.webContents.addWorkSpace(__dirname);
|
win.webContents.addWorkSpace(__dirname);
|
||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -763,13 +763,13 @@ An example of sending messages from the main process to the renderer process:
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
// In the main process.
|
// In the main process.
|
||||||
let mainWindow = null;
|
let win = null;
|
||||||
|
|
||||||
app.on('ready', () => {
|
app.on('ready', () => {
|
||||||
mainWindow = new BrowserWindow({width: 800, height: 600});
|
win = new BrowserWindow({width: 800, height: 600});
|
||||||
mainWindow.loadURL(`file://${__dirname}/index.html`);
|
win.loadURL(`file://${__dirname}/index.html`);
|
||||||
mainWindow.webContents.on('did-finish-load', () => {
|
win.webContents.on('did-finish-load', () => {
|
||||||
mainWindow.webContents.send('ping', 'whoooooooh!');
|
win.webContents.send('ping', 'whoooooooh!');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
|
@ -87,7 +87,7 @@ To solve this, you can turn off node integration in Electron:
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
// In the main process.
|
// In the main process.
|
||||||
let mainWindow = new BrowserWindow({
|
let win = new BrowserWindow({
|
||||||
webPreferences: {
|
webPreferences: {
|
||||||
nodeIntegration: false
|
nodeIntegration: false
|
||||||
}
|
}
|
||||||
|
|
|
@ -88,24 +88,24 @@ const {BrowserWindow} = electron;
|
||||||
|
|
||||||
// Keep a global reference of the window object, if you don't, the window will
|
// 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.
|
// be closed automatically when the JavaScript object is garbage collected.
|
||||||
let mainWindow;
|
let win;
|
||||||
|
|
||||||
function createWindow() {
|
function createWindow() {
|
||||||
// Create the browser window.
|
// Create the browser window.
|
||||||
mainWindow = new BrowserWindow({width: 800, height: 600});
|
win = new BrowserWindow({width: 800, height: 600});
|
||||||
|
|
||||||
// and load the index.html of the app.
|
// and load the index.html of the app.
|
||||||
mainWindow.loadURL(`file://${__dirname}/index.html`);
|
win.loadURL(`file://${__dirname}/index.html`);
|
||||||
|
|
||||||
// Open the DevTools.
|
// Open the DevTools.
|
||||||
mainWindow.webContents.openDevTools();
|
win.webContents.openDevTools();
|
||||||
|
|
||||||
// Emitted when the window is closed.
|
// Emitted when the window is closed.
|
||||||
mainWindow.on('closed', () => {
|
win.on('closed', () => {
|
||||||
// Dereference the window object, usually you would store windows
|
// Dereference the window object, usually you would store windows
|
||||||
// in an array if your app supports multi windows, this is the time
|
// in an array if your app supports multi windows, this is the time
|
||||||
// when you should delete the corresponding element.
|
// when you should delete the corresponding element.
|
||||||
mainWindow = null;
|
win = null;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -126,7 +126,7 @@ app.on('window-all-closed', () => {
|
||||||
app.on('activate', () => {
|
app.on('activate', () => {
|
||||||
// On OS X it's common to re-create a window in the app when the
|
// On OS X it's common to re-create a window in the app when the
|
||||||
// dock icon is clicked and there are no other windows open.
|
// dock icon is clicked and there are no other windows open.
|
||||||
if (mainWindow === null) {
|
if (win === null) {
|
||||||
createWindow();
|
createWindow();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -29,14 +29,14 @@ app.commandLine.appendSwitch('ppapi-flash-path', '/path/to/libpepflashplayer.so'
|
||||||
app.commandLine.appendSwitch('ppapi-flash-version', '17.0.0.169');
|
app.commandLine.appendSwitch('ppapi-flash-version', '17.0.0.169');
|
||||||
|
|
||||||
app.on('ready', () => {
|
app.on('ready', () => {
|
||||||
mainWindow = new BrowserWindow({
|
win = new BrowserWindow({
|
||||||
width: 800,
|
width: 800,
|
||||||
height: 600,
|
height: 600,
|
||||||
webPreferences: {
|
webPreferences: {
|
||||||
plugins: true
|
plugins: true
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
mainWindow.loadURL(`file://${__dirname}/index.html`);
|
win.loadURL(`file://${__dirname}/index.html`);
|
||||||
// Something else
|
// Something else
|
||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
|
@ -59,9 +59,9 @@ app.commandLine.appendSwitch('widevine-cdm-path', '/path/to/widevinecdmadapter.p
|
||||||
// The version of plugin can be got from `chrome://plugins` page in Chrome.
|
// The version of plugin can be got from `chrome://plugins` page in Chrome.
|
||||||
app.commandLine.appendSwitch('widevine-cdm-version', '1.4.8.866');
|
app.commandLine.appendSwitch('widevine-cdm-version', '1.4.8.866');
|
||||||
|
|
||||||
let mainWindow = null;
|
let win = null;
|
||||||
app.on('ready', () => {
|
app.on('ready', () => {
|
||||||
mainWindow = new BrowserWindow({
|
win = new BrowserWindow({
|
||||||
webPreferences: {
|
webPreferences: {
|
||||||
// The `plugins` have to be enabled.
|
// The `plugins` have to be enabled.
|
||||||
plugins: true
|
plugins: true
|
||||||
|
|
Loading…
Reference in a new issue