Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: update Quick Start Guide for Electron 12 (#28223)
* docs: Update Quick Start Guide for Electron 12 With `contextIsolation` enabled by default in Electron 12, the Getting Started Guide no longer works as it is written. In order for the basic example to display values from `process.versions`, we need to add a `preload.js` to the example. * fix: annotate preload code block with a language * docs: update quick-start Fiddle example to use preload to provide version info * fix: ensure example files end in a newline * docs: add security warning to instructions for turning off contextIsolation Co-authored-by: John Kleinschmidt <jkleinsc@github.com> * docs: treat preload as an adjective instead of a noun Co-authored-by: John Kleinschmidt <jkleinsc@github.com> Co-authored-by: John Kleinschmidt <jkleinsc@github.com>
- Loading branch information
1 parent
80f89a3
commit b6ff12e
Showing
4 changed files
with
71 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,31 @@ | ||
const { app, BrowserWindow } = require('electron') | ||
const path = require('path') | ||
|
||
function createWindow () { | ||
const win = new BrowserWindow({ | ||
width: 800, | ||
height: 600, | ||
webPreferences: { | ||
nodeIntegration: true, | ||
contextIsolation: false | ||
preload: path.join(__dirname, 'preload.js') | ||
} | ||
}) | ||
|
||
win.loadFile('index.html') | ||
} | ||
|
||
app.whenReady().then(createWindow) | ||
app.whenReady().then(() => { | ||
createWindow() | ||
|
||
app.on('activate', () => { | ||
if (BrowserWindow.getAllWindows().length === 0) { | ||
createWindow() | ||
} | ||
}) | ||
}) | ||
|
||
app.on('window-all-closed', () => { | ||
if (process.platform !== 'darwin') { | ||
app.quit() | ||
} | ||
}) | ||
|
||
app.on('activate', () => { | ||
if (BrowserWindow.getAllWindows().length === 0) { | ||
createWindow() | ||
} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
window.addEventListener('DOMContentLoaded', () => { | ||
const replaceText = (selector, text) => { | ||
const element = document.getElementById(selector) | ||
if (element) element.innerText = text | ||
} | ||
|
||
for (const type of ['chrome', 'node', 'electron']) { | ||
replaceText(`${type}-version`, process.versions[type]) | ||
} | ||
}) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
b6ff12e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#35350
b6ff12e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Vana1233
b6ff12e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#35374