docs: fix code example in process-model.md (#30690)

* Update process-model.md

the demo have two error: 
- at macos, close all window, the app will not quite, unless press cmd + q
- attach preload.js, use preload prop that is member of `webPreferences` property of `BrowserWindow` controller argument

* Update docs/tutorial/process-model.md

Co-authored-by: Erick Zhao <erick@hotmail.ca>

Co-authored-by: Cheng Zhao <github@zcbenz.com>
Co-authored-by: Erick Zhao <erick@hotmail.ca>
This commit is contained in:
jiang kun 2021-09-01 19:46:32 +08:00 committed by GitHub
parent 63b35403ef
commit f533c44912
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -83,7 +83,7 @@ As a practical example, the app shown in the [quick start guide][quick-start-lif
uses `app` APIs to create a more native application window experience. uses `app` APIs to create a more native application window experience.
```js title='main.js' ```js title='main.js'
// quitting the app when no windows are open on macOS // quitting the app when no windows are open on non-macOS platforms
app.on('window-all-closed', () => { app.on('window-all-closed', () => {
if (process.platform !== 'darwin') app.quit() if (process.platform !== 'darwin') app.quit()
}) })
@ -148,7 +148,9 @@ A preload script can be attached to the main process in the `BrowserWindow` cons
const { BrowserWindow } = require('electron') const { BrowserWindow } = require('electron')
//... //...
const win = new BrowserWindow({ const win = new BrowserWindow({
webPreferences: {
preload: 'path/to/preload.js' preload: 'path/to/preload.js'
}
}) })
//... //...
``` ```